• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

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?
0
technolutions
Asked:
technolutions
  • 3
  • 2
1 Solution
 
Farhan KaziSystems EngineerCommented:
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
0
 
technolutionsAuthor Commented:
My browse button is grayed out?!
0
 
technolutionsAuthor Commented:
If I type in the path of the batch file without browsing it doesn't work when I stop the service.
0
 
Farhan KaziSystems EngineerCommented:
Did you select "Run a program" from "first failure" drop down list ?
0
 
Farhan KaziSystems EngineerCommented:
It will only work in case of service failure.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now