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

A. Under Windows 2000 the built in support for service recovery has been greatly enhanced and using the Computer Management MMC, Services and Applications - Services under the Recovery tab of each service are a number of definable 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 script which 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):

sc query spooler &gt; state.txt<br>
find "STOPPED" state.txt<br>
if %errorlevel% EQU 0 goto error<br>
sleep 300<br>
goto start<br><br>
sc start spooler<br>
sleep 5<br>
goto start

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

There are 3rd products for this purpose also, e.g., Service Plus from

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.