Batch file - check if service is running every 5 minutes, if not start it

Trey22

Diamond Member
Oct 31, 2003
5,540
0
76
Here is what I have so far. I just need this to check if the service is running, and if so, leave it be, but if it's not, to start it up. I'd like this check to happen every 5 minutes or so.

Thanks in advance.

:start
echo %date% %time% >> servicecheck.log
net start | find "doorsnxtsvr" >> servicecheck.log 2>>&1
if not .%errorlevel%.==.0. goto trouble

sleep 300
goto start

:trouble
net start "doorsnxtsvr"
 

KLin

Lifer
Feb 29, 2000
30,120
500
126
So what's your question? Is the script you posted not working correctly?
 

bsobel

Moderator Emeritus<br>Elite Member
Dec 9, 2001
13,346
0
0
Why not set the recovery parameters for the service and be done with it?
 

KLin

Lifer
Feb 29, 2000
30,120
500
126
Originally posted by: bsobel
Why not set the recovery parameters for the service and be done with it?

That would be much better than the batch script IMO. Set the recovery parameters to restart the service.
 

Trey22

Diamond Member
Oct 31, 2003
5,540
0
76
Originally posted by: KLin
Originally posted by: bsobel
Why not set the recovery parameters for the service and be done with it?

That would be much better than the batch script IMO. Set the recovery parameters to restart the service.

Original question was if the script looked like it would do the job... especially the sleep parameter, which wasn't working for me.

Thx for the other ideas, I guess there are easier ways to accomplish this.

Cheers,

Trey