c# code : Start Windows service

public void StartService(string ServiceName)
{
ServiceController sc = new ServiceController(ServiceName);
if (sc != null && sc.Status == ServiceControllerStatus.Stopped)
{

sc.Start();
sc.WaitForStatus(ServiceControllerStatus.Running);

}
}

No comments:

Post a Comment