Jump to content

Recommended Posts

Posted (edited)

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??

Edited by Newton
Posted

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)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...