all groups > vb.net > february 2005 >
You're in the

vb.net

group:

Restart a Windows Service using vb.net


Restart a Windows Service using vb.net Sean
2/28/2005 11:42:38 PM
vb.net: Greetings,

Is there a sample code that shows how to restart a windows service using
VB.Net?

Sean

Re: Restart a Windows Service using vb.net Sean
3/1/2005 7:34:39 AM
thanks

[quoted text, click to view]

RE: Restart a Windows Service using vb.net v-phuang NO[at]SPAM online.microsoft.com (
3/1/2005 8:33:48 AM
Hi

You may try to see if the code below helped you.
Imports System.ServiceProcess
Module Module2
Public Sub Main()
Dim sc As New ServiceController("Themes")
sc.Stop()
Console.ReadLine()
sc.Start()
End Sub
End Module

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Re: Restart a Windows Service using vb.net Jay B. Harlow [MVP - Outlook]
3/1/2005 9:31:39 AM
Sean,
I use code the following, which is similar to Peter's code, to "Restart" a
service:

Dim controller As New ServiceController("Themes")
controller.Stop()
controller.WaitForStatus(ServiceControllerStatus.Stopped)
controller.Start()

Note the WaitForStatus waits until the service has come to a complete halt
before starting it again.

Hope this helps
Jay

[quoted text, click to view]

AddThis Social Bookmark Button