|I want to put together a batch file that will auto start a service if it is found to not be running. Here is what I've put together thus far. It seems to work, but I want to see what those think who are smarter than I.... |
Here we go...
date /t >>%batchlog%
time /t >>%batchlog%
Echo Checking status of Service... >>%batchlog%
sc query "bthserv" > %templog%
findstr /i "STATE" %templog% > %batchlog1%
Find /i "Stopped" %batchlog1%
IF not errorlevel=1 goto NOTRUNNING
IF errorlevel=1 goto RUNNING
echo Service was not running, will start now... >>%batchlog%
SC START "bthserv"
Echo The service is running, will exit now. >>%batchlog%
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>%batchlog%
the pauses are in there for when I was testing. To automate, they will be replaced with timeouts.