How to start /stop a windows service through a Windows Form application

 ̄綄美尐妖づ 提交于 2019-12-02 12:27:50

You want to use the ServiceController class.

Initialize it with your service name, and call Start() and Stop() methods.

using System.ServiceProcess;
ServiceController sc = new ServiceController("My service name");
if (sc.Status == ServiceControllerStatus.Stopped)
{
  sc.Start();
}
//etc..
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!