I want to run a scheduled task every time after a given service is started. I have looked for a way to set a trigger on a service start, so that the service in question may be started automatically at system start or manual restarted on run time.

The System it should work on is a Windows Server 2008 R2.

Detailed description:

  • On server A an UMS service is running
  • On server B a FAX line service is running and connects to the UMS service on server A
  • If server A or the UMS service on it is restarted the FAX service on server b is loosing its connection and has to be restarted.

So, I want to schedule a script on server A with the start of the UMS service and restart the FAX Line service on server B via net stop/start from that.

The missing point is, how would I define the trigger for the task scheduler?


You can do this using Task Scheduler with a Trigger set up as follows:

Begin the task: On an event

Settings: Custom

Click the New Event Filter... button

Select the XML tab

Check the Edit query manually checkbox

Click the Yes button

Enter the following in the text box, replacing your service name:

   <Query Id="0"> 
      <Select Path="System"> 
         *[EventData[Data[@Name='param1'] and (Data='YOUR SERVICE NAME')]] 
         *[EventData[Data[@Name='param2'] and (Data='running')]] 

More information on XML Event filtering here: Advanced XML filtering in the Windows Event Viewer.

Note: When using a non English Windows 'Data' for 'param2' depends on the system's language. E.g. for a German version of Windows it is 'Ausgeführt' instead of 'running'.

  • What is the Path here? how I can find out path of the service, that I want to work with? – Mehdi Dehghani Feb 5 '18 at 15:54
  • 1
    @MehdiDehghani you don't need to change the Path property - that is simply referring to the System Event Log. The only thing you need to change is YOUR SERVICE NAME – Shevek Feb 5 '18 at 22:02
  • I want to run task when Windows Update service started, I use wuauserv and Windows Update, but doesn't work, can you help me on this? – Mehdi Dehghani Feb 6 '18 at 5:14
  • 1
    @Mehdi Dehghani Follow this tutorial. nucuta.com/how-to-disable-automatic-updates-on-windows-10/… – Don Dilanga Feb 6 '19 at 12:02
  • Glad it worked out. This answer doesn't work because there is no such thing as "running". there are only few options like disabled, auto start (automatic in services), demand start (manual in services). there are other mistakes too like no param 3, and problems in the format. – Don Dilanga Feb 6 '19 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.