It is simple Batch file that allow to start a windows service ,with checking if it is already running or not
This can re-script as you need.For example it can add to sheduled task for automatic starting and stopping of specified service.For that ,a littile change should be made on file
Replace line 'Set Report=!Report!Running:' with net stop [serviceName]
suggessions are appriciable
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * You need to add service names inside the script
:: * Successful run will generate "ServiceStatusRpt.txt"
:: * Copy and Paste following script into notepad and save it with any name having .cmd or bat extension.
:: Batch Script Start
@ECHO OFF
SETLOCAL EnableDelayedExpansion
WMIC /NODE:"." SERVICE WHERE "Name='MSSQLSERVER' AND State='Running'" GET Status 2>NUL |FIND /I "OK" >NUL
IF NOT ERRORLEVEL 1 (
Set Report=!Report!Running:
) ELSE (
net start MSSQLSERVER
)
ECHO !Report:~0,-1!>>ServiceStatusRpt.txt
Goto EndScript
:EndScript
EXIT /B 0
:: Batch Script End
Posted by
Unknown
Friday, August 21, 2009
0 comments