问题
I would like to launch script after windows service start or restart. Like monitor wsupdate and at start or restart execute a batch script test.bat
Any ideas ?
回答1:
That could be easily done with a scheduled task:
You just need to:
1) Start and Stop the Service to got the appropriate Events in the Eventlog.
2) taskschd.msc and create a new Costum Task. As Trigger you can select the Events created before with the start and/or stop action.
3) As Action call your cmd/bat, whatever you want.
Hint: You also can export the Event in the XML Format, explained here: http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx and then import the XML Snippet into the Scheduld Task.
来源:https://stackoverflow.com/questions/31606840/launch-script-after-windows-service-start