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 stopped
controller.Start();//wait until started
controller.Refresh();Console.WriteLine(controller.Status.ToString());}
Comments
Post a Comment