I have a windows service running on a Windows 2003 server. Under the properties option when you right click the service, there is an option to restart the service if it fails. The options available are for the first, second and any subsequent failures.

I tried to use this option to restart the service when not running but it looks like it only restarts the service if the service fails as a result of a failure. The problem i have is that if there is a failure, the service picks this up and shuts down the service 'gracefully'. This means it is not being restarted.

Is there a way i can restart the service regardless of whether it stopped because of a failure or if it stopped gracefullly?



For a misbehaving service like that, I'd create a small script that checks if it's running and starts it if it isn't. Then I'd use scheduled tasks to run the script every 5 minutes or so.

Example script (checks for the spooler service):

@echo off
Rem Look for the Print Spooler service in the list of started services
net start | find /i "Print Spooler"
Rem if not found, start it and a restart occurred.
if "%errorlevel%"=="1" (
   echo Service "Print Spooler" restarted at %time% on %date% by Script %0>>c:\ServiceRestart.Log
   net start "Print Spooler"
| improve this answer | |

What service is it? I had a weird issue with the MS Fax service once. I resolved it by checking processes under Task Manager, ending the process if it is listed, then opening a Command Prompt and typing:

net start faxsvc.exe

You can use net stop faxsvc.exe to terminate the service as well.

Another thing is to check for dependencies and restart those as well, i.e. those that the fax service depends on.

EDIT: I guessed this might help, but I didn't read your question very well. I know there's a program called Service Hawk available, but it costs money. Another idea would be to match a batch file that will restart the service every xx seconds/minutes/hours/however long the duration between the service running and failing is.

| improve this answer | |
  • It is an application we wrote ourselves. Its not one of the services that come with windows. The problem is that when the program detects a failure it does shutdown but it doesnt shutdown with a failure. Im guessing it is supposed to return an error flag when it shuts down but it probably doesnt. – ziggy Feb 1 '11 at 10:10

Here is the answer!

Using the following Powershell command can able check & start required service

$A = get-service AdobeARMservice 
if ($A.Status -eq "Stopped") {$A.start()} elseIf ($A.status -eq "Running") {Write-Host -ForegroundColor Yellow $A.name "is running"}   
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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