How can I configure a service to automatically restart if it stops?

John Savill

December 4, 1999

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. Under Windows 2000 the built in support for service recoveryhas been greatly enhanced and using the Computer Management MMC, Services andApplications - Services under the Recovery tab of each service are a number ofdefinable actions to take in the event of the service stopping:

  • Take no action

  • Restart the Service

  • Run a user defined file

  • Reboot the machine

Click here to view image

This is not possible under Windows NT 4.0 however by writing a custom scriptwhich runs continuously you could achieve a similar effect using a batch file,for example (we use the SC.EXE and SLEEP.EXE resource kit utilities):

:start
sc query spooler > state.txt
find "STOPPED" state.txt
if %errorlevel% EQU 0 goto error
sleep 300
goto start

:error
sc start spooler
sleep 5
goto start

You could add a server name, e.g. sc \server query etc. if you want to checka remote system. Basically the above checks every 5 minutes but you can changeand check multiple services if you like.

There are 3rd products for this purpose also, e.g., Service Plus from http://svclight.activeplus.com/.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like