Solved

Running a batch file when a service stops.

Posted on 2008-06-22
5
414 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

939 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

7 Experts available now in Live!

Get 1:1 Help Now