Mega Code Archive

 
Categories / C# by API / System Serviceprocess
 

ServiceController Stop()

using System; using System.ServiceProcess; class MainClass {   public static void Main()    {     ServiceController scAlerter = new ServiceController("Alerter");     Console.WriteLine(scAlerter.DisplayName);     Console.WriteLine(scAlerter.CanStop);     scAlerter.Stop();     Console.WriteLine("Service stopped");     scAlerter.Start();     Console.WriteLine("Service started");   } }