Solved

Running a batch file when a service stops.

Posted on 2008-06-22
5
410 Views
Last Modified: 2012-05-05
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
Comment
Question by:technolutions
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:farhankazi
ID: 21841840
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
 

Author Comment

by:technolutions
ID: 21843710
My browse button is grayed out?!
0
 

Author Comment

by:technolutions
ID: 21843728
If I type in the path of the batch file without browsing it doesn't work when I stop the service.
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 21843733
Did you select "Run a program" from "first failure" drop down list ?
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 250 total points
ID: 21843739
It will only work in case of service failure.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How can I do this in Pyhton? 12 75
excel file 5 53
Installing Git and chefdk via bat script 8 22
IBMi supported MySQL versions. 2 8
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now