Restart service based on Event log

G

Guest

I have a problem where a program that runs as a service shuts down every now
and then and I cannot seem to get the vendor to fix the program. Restarting
the service takes care the problem.

When the service shuts down it writes an event in the Application log so I
was hoping that there might be a way that I can trap the error and when it
occurs, issue a command to stop and restart the service. Is there anything
like that?
 
M

Mark V

No Spam wrote in
I have a problem where a program that runs as a service shuts down
every now and then and I cannot seem to get the vendor to fix the
program. Restarting the service takes care the problem.

When the service shuts down it writes an event in the Application
log so I was hoping that there might be a way that I can trap the
error and when it occurs, issue a command to stop and restart the
service. Is there anything like that?

What OS?
Get into the Properties for the Service and setup the Failure Options
(Recovery tab) to restart itself on error.
 
G

Guido ( Chris Harper )

I would run the program / service in a batch file and follow the program with a
custom written one that checks the Applications log file for the shut down
event, and have the program exit on error depending on whether it should restart
or not, then use batch file error trapping to branch back to start program if
needed.
Of course the custom program should also remove or alter the shutdown event
record so it does not "see" it on subsequent runs.
 
M

Mark V

No Spam wrote in
It is a Windows NT 4.0 Server. Are their any white papers on this
process?

I don't think NT4 has that feature, but I cannot recall it now. W2K
Pro/Server do.

Clearly the vendor needs to fix it.

Instead of EventLog perhaps a looping batchfile that queries for the
Service state = "Running" would work. Part of that would involve
perhaps using sc.exe (Resource Kit) or psservice.exe (sysinternals)
to query the service manager for the Service state.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top