Kevin,
I normally use ServiceController.Status:
http://msdn.microsoft.com/library/de...tatusTopic.asp
' Toggle the Telnet service -
' If it is started (running, paused, etc), stop the service.
' If it is stopped, start the service.
Dim sc As New ServiceController("Telnet")
Console.WriteLine("The Telnet service status is currently set to
{0}", sc.Status)
If sc.Status = ServiceControllerStatus.Stopped _
Or sc.Status = ServiceControllerStatus.StopPending Then
' Start the service if the current status is stopped.
Console.WriteLine("Starting the Telnet service...")
sc.Start()
Else
' Stop the service if its status is not set to "Stopped".
Console.WriteLine("Stopping the Telnet service...")
sc.Stop()
End If
' Refresh and display the current service status.
sc.Refresh()
Console.WriteLine("The Telnet service status is now set to {0}.",
sc.Status)
If you are changing the status, ServiceController.WaitForStatus can be
useful:
http://msdn.microsoft.com/library/de...atusTopic1.asp
For example, to "restart" a service I use something like:
Dim sc As New ServiceController("Telnet")
sc.Stop()
sc.WaitForStatus(ServiceControllerStatus.Stopped)
sc.Start()
Hope this helps
Jay
"Kevin L" <no_spam@not_real_email.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
How do I check to see if a particular service is running?