Wednesday, December 5, 2007

Start/Stop Windows Services from ASP.Net 2.0

Need to add the reference System.ServiceProcess
Imports System.ServiceProcess

Dim sc As New ServiceController()
sc.ServiceName = "W3SVC"
Console.WriteLine("The Alerter service status is currently set to {0}", sc.Status)
If sc.Status.Equals(ServiceControllerStatus.Stopped) Then
sc.Start()
Else
sc.Stop()
End If

We can do all related to the service controller