0

I want a batch program that will restart a service if that service currently throws a error in eventviewer .

2
  • 1
    Usually setting the service to Automatic will make sure that it restarts on failure, no?
    – MPelletier
    Mar 4, 2011 at 19:17
  • Are you talking about a Windows service? Is the service crashing when it gets the error you're looking at, or is it a non-fatal error?
    – E.Z. Hart
    Mar 4, 2011 at 19:18

2 Answers 2

0

If you open the Services management console (services.msc), go to the Properties for the service, and select the 'Recovery' tab, you can set the service to restart after failure.

2
  • The services is any service running in windows
    – shiva
    Mar 4, 2011 at 19:35
  • I Have set it but does not work .If there is a Error for the service Its not a failure of service
    – shiva
    Mar 4, 2011 at 20:20
0

There's no way for a batch file to know the service "throws an error in eventviewer", since a batch file can't access the event logs and wouldn't get notified there was an event there if it could.

The usual way to deal with this issue is to set the service to restart after failure in the service's properties. The other option used is to write an application that monitors the service and restarts it if it stops. It's usually called a 'guardian' application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.