Link to home
Start Free TrialLog in
Avatar of technolutions
technolutionsFlag for South Africa

asked on

Running a batch file when a service stops.

I want to setup my servers so that when a windows service stops that it runs a batch file which triggers a .ps1 script that sends me a mail. I know that my bat file works but how can I make windows run that bat file when a service stops?
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

You can configure service "Recovery" option to "Run a program" (or batch file) when service fails.

Click Start -> Run -> Services.msc -> Right click on Service -> Properties -> Recovery -> Under First failure drop down list select "Run a program" -> Click browse button and select batch file that you want to run.

Hope this helps!
Farhan
Avatar of technolutions

ASKER

My browse button is grayed out?!
If I type in the path of the batch file without browsing it doesn't work when I stop the service.
Did you select "Run a program" from "first failure" drop down list ?
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial