PC Review


Reply
Thread Tools Rate Thread

How to control the state of a service in win2000?

 
 
Kenshiro
Guest
Posts: n/a
 
      19th Feb 2004
Hi
I would like to know if exist a way to control the state of a service
in win2000? for example a program (Microsoft or freeware) that send a
popup message if the service "Server" is stopped.
Can you help me?

Thanks
Ken
 
Reply With Quote
 
 
 
 
Jerold Schulman
Guest
Posts: n/a
 
      19th Feb 2004
On 19 Feb 2004 02:51:24 -0800, (E-Mail Removed) (Kenshiro) wrote:

>Hi
>I would like to know if exist a way to control the state of a service
>in win2000? for example a program (Microsoft or freeware) that send a
>popup message if the service "Server" is stopped.
>Can you help me?
>
>Thanks
>Ken



See tip 3014 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Reply With Quote
 
Torgeir Bakken (MVP)
Guest
Posts: n/a
 
      19th Feb 2004
Kenshiro wrote:

> I would like to know if exist a way to control the state of a service
> in win2000? for example a program (Microsoft or freeware) that send a
> popup message if the service "Server" is stopped.
> Can you help me?


Hi

You can use WMI to monitor the state change of a service.

Try the vbscript below (put it in a file with .vbs as file extension name,
will loop forever until terminated).


' Name of service to monitor, note, this is NOT the display name
strServiceName = "LanmanServer"

strComputer = "." ' use . for local computer

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService. _
ExecNotificationQuery("Select * from __instancemodificationevent " _
& "within 5 where TargetInstance isa 'Win32_Service' " _
& "AND TargetInstance.Name = '" & strServiceName & "'")
i = 0
Do While i = 0
Set objService = colServices.NextEvent
If objService.TargetInstance.State <> objService.PreviousInstance.State Then
Wscript.Echo objService.TargetInstance.Name _
& " is " & objService.TargetInstance.State _
& ". The service previously was " & _
objService.PreviousInstance.State & "."
End If
Loop


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
ASP .Net State Service titus12 Windows XP Help 2 29th Jan 2008 12:21 PM
How to manage child control state for Custom Web Control? ChrisMiddle10@gmail.com Microsoft ASP .NET 0 19th Oct 2006 04:26 AM
Where can I state questions for Win2000? =?Utf-8?B?d2luZzAwNw==?= Windows XP General 17 8th May 2006 07:55 PM
ASP .NET State Service Issue - Not Replicating state kamalesh Microsoft ASP .NET 0 19th Feb 2006 08:25 PM
Quality Control Testing with Win2000 Service Packs John Olbert Microsoft VC .NET 2 9th Sep 2003 11:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:52 AM.