New
#1
Batch file to start a service if the service is not running
Here what I want :
if servicename is running, do nothing.
if servicename is not running, then start servicename, then record the date and time.
based on my search [COLOR=blue ! important][COLOR=blue ! important]online[/COLOR][/COLOR], here is what I have so far:
net start | find "servicename" > nul 2>&1
if not .%errorlevel%.==.0. goto startservice
:startservice
net start "servicename"
echo service restarts @ %date% %time% >> C:\checklog.txt
pause
My problem is:
It looks like that the If statement is not working. Every time I run this batch file, it runs through all the command lines.
and I got a error message said the service is already running.
Please advice.