I have the following script....
-----------------------------------------------------------------
Set objComputer = GetObject("WinNT://computername,computer")
objComputer.Filter = Array("Service")
strServiceName = "MYSERVICE"
For Each aService In objComputer
If LCase(strServiceName) = LCase(aService.Name) Then
if aService.Status = 1 then
'Service stopped so start it
aService.start
end if
End If
Next
------------------------------------------------------------------
All it does is check for a service and if its stopped start it.
I'd like to check the status every X minutes (say 15 for now) automaticly how would you recommend going about this, something self contained in the script would be ideal
something like
do
'sleep15minutes check service
loop
or
as a scheduled task??
Last edited by Newton; 18th June 2009 at 03:45 PM.
You can configure a scheduled task to run every 15 minutes - just look in the advanced properties of task scheduler - but why do you want to do this?
If you look at the properties of the service in service manager you'll see a "what to do if the service stops" and there's a load of things, including restart it.
You can also specify what to do it it stops more than once so you could have "restart" on first and second failure but "run a program" on the third - that program could send an email to you to alert you to trouble.
You can also control how long the count lasts for (ie it isn't "first ever failure" but "first failure in 15 minutes" or whatever you choose)
There are currently 1 users browsing this thread. (0 members and 1 guests)