12-27-2006 02:56 AM
With that, I created and deployed a batch file with "Net Start SQLSERVERAGENT" command and uses Scheduled Task Policy to call the file at 2:30am.
However, most of the time, the service is always running, and the policy still executes itself at 2:30am (of course, it does not pose any impact nor do anything, because it has already running)
Is there a command to add to the batch file in order to tell the policy only executes at 2:30am IF the service isn't running??
Solved! Go to Solution.
12-27-2006 03:20 AM
I would use VB script for this need.
You can use a vb script which connects to a wmi and checks if the service is running, and tries to start the service if it is not running.
12-27-2006 04:16 AM
You can use a scheduled task policy again.
12-28-2006 01:10 AM
net start | findstr "SQLSERVERAGENT"
if %ERRORLEVEL% neq 0 net start SQLSERVERAGENT
12-28-2006 02:59 AM
net start | find /i "MyServiceName"
if %errorlevel%==0 echo "service already running"
Simply "net start" will give you list of running services on the system.