Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCSE > Script for monitoring a Service

Reply
Thread Tools

Script for monitoring a Service

 
 
=?Utf-8?B?SmF2aWVy?=
Guest
Posts: n/a
 
      08-03-2007
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
 
Reply With Quote
 
 
 
 
John R
Guest
Posts: n/a
 
      08-04-2007

"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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Automated Port Monitoring / Auditing Service Hoss Computer Security 0 07-19-2007 04:32 AM
service for file monitoring rohit Python 5 04-22-2007 10:42 AM
Directory/File Monitoring Service in WindowsXP Question zdk C++ 1 07-27-2006 04:40 AM
Monstastic: the free website monitoring service that doesn't suck supercobra Java 2 01-10-2006 01:25 AM
Monitoring windows service Wally ASP .Net 5 10-03-2004 08:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57