c# code : how to stop windows service

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

sc.Stop();
sc.WaitForStatus(ServiceControllerStatus.Stopped);

}
}

No comments:

Post a Comment