Start/Stop windows service from C#
using System.ServiceProcess;public void Test(){ServiceController controller = new ServiceController();controller.MachineName = ".";controller.ServiceName = "MyService";controller.Stop();//wait until stoppedcontroller.Start();//wait until startedcontroller.Refresh();Console.WriteLine(controller.Status.ToString());}
Comments
Post a Comment