Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: How can you tell is an NT Service is running?


Message #1 by "Paul Whygle" <paul@g...> on Mon, 30 Dec 2002 20:13:50
If you create a form with 2 list boxes on it
'ListRunning'
'ListStopped'

Add one command button and a text box
'txtMachine'

Then in the command button sub paste this code

  If LenB(txtMachine) > 0 Then
    Dim strService As String
    ' Check status of IIS on remote machine
    Set wbemServices = GetObject("winmgmts:\\" & txtMachine)
    Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
    ListRunning.Clear
    ListStopped.Clear
    For Each wbemObject In wbemObjectSet
      strService = ""
      strService = wbemObject.state & " - "
      strService = strService & wbemObject.Name
      Select Case wbemObject.state
        Case "Running"
          ListRunning.AddItem strService
        Case Else
          ListStopped.AddItem strService
      End Select
    Next
  End If


That may be a bit more than what you are looking for but it gives you what 
you need!


Dave(Hobbes)
rwaters44@h...

----Original Message Follows----
From: "Paul Whygle" <paul@g...>
Reply-To: "professional vb" <pro_vb@p...>
To: "professional vb" <pro_vb@p...>
Subject: [pro_vb] How can you tell is an NT Service is running?
Date: Mon, 30 Dec 2002 20:13:50

Is there a way to tell is a particular service is
running?  if so can you post a code snippet?

If it is possible can you tell if the service is in a
start/stop/paused state?

Thank you,
Paul


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 3 months FREE*. 
http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= 
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_stopmorespam_3mf


  Return to Index