![]() |
|
|
|||||||
![]() |
MCSE - Script for monitoring a Service |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
I've been working almost three months on a script, it starts the service when
I executed it, but I need a script that runs all the time and checks the service status, like a endless loop. the language I'm using it's VBscript, this is the code. besides all I wanna do is that this script check the service status every 1 milisecond and if the service is stopped then the script starts the service. Option Explicit Dim objWMIService, objItem, objService Dim colListOfServices, strComputer, strService, intSleep strComputer = "." intSleep = 1000 strService = " 'Messenger' " Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where State = 'Stopped' and Name = 'Messenger'") For Each objService in colListOfServices WSCript.Sleep intSleep objService.StartService() Next WScript.Echo "Your "& strService & " service has Started" WScript.Quit ' End of Example WMI script to Start / Stop services =?Utf-8?B?SmF2aWVy?= |
|
|
|
|
#2 |
|
Posts: n/a
|
"Javier" <> wrote in message news:8CB56AF0-9383-4F61-B01A-... > I've been working almost three months on a script, it starts the service > when > I executed it, but I need a script that runs all the time and checks the > service status, like a endless loop. the language I'm using it's VBscript, > this is the code. besides all I wanna do is that this script check the > service status every 1 milisecond and if the service is stopped then the > script starts the service. > > Option Explicit > Dim objWMIService, objItem, objService > Dim colListOfServices, strComputer, strService, intSleep > strComputer = "." > intSleep = 1000 > > > strService = " 'Messenger' " > Set objWMIService = GetObject("winmgmts:" & > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > Set colListOfServices = objWMIService.ExecQuery ("Select * from > Win32_Service Where State = 'Stopped' and Name = 'Messenger'") > > For Each objService in colListOfServices > > WSCript.Sleep intSleep > objService.StartService() > Next > WScript.Echo "Your "& strService & " service has Started" > WScript.Quit > ' End of Example WMI script to Start / Stop services You do know about the options on the 'recovery' tab on the service properties? John R John R |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Novice needs help with Adserver.Adtech.de | CPU Rookie | General Help Related Topics | 3 | 05-10-2008 05:54 PM |
| Am new here and need help with virus/spyware | cm punk | General Help Related Topics | 1 | 11-13-2006 11:04 AM |
| Trojan Horse! AHHH! | okstatefan@swbell.net | A+ Certification | 11 | 02-08-2005 07:12 PM |
| Re: High Gasoline Prices Create A+ Service Opportunities | Frederic | A+ Certification | 3 | 01-17-2004 11:38 PM |
| Re: Home service calls | Ghost | A+ Certification | 3 | 07-24-2003 10:36 PM |