Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running a batch file when a service stops.

Posted on 2008-06-22
5
Medium Priority
?
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Farhan Kazi
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:Farhan Kazi
ID: 21843733
Did you select "Run a program" from "first failure" drop down list ?
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 750 total points
ID: 21843739
It will only work in case of service failure.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

715 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