3 回答
TA贡献1790条经验 获得超9个赞
好的,这是真正为我工作的东西,它已经在具有不同操作系统(Vista,XP,Win2k,Win2003服务器)的多台计算机上进行了测试。
该代码已从此处获取,因此无论谁编写此代码都应归功于此。
将dll或源文件添加到项目后,请确保添加ServiceTools命名空间,然后您可以访问一些非常方便的功能,例如...
//Installs and starts the service
ServiceInstaller.InstallAndStart("MyServiceName", "MyServiceDisplayName", "C:\\PathToServiceFile.exe");
//Removes the service
ServiceInstaller.Uninstall("MyServiceName");
//Checks the status of the service
ServiceInstaller.GetServiceStatus("MyServiceName");
//Starts the service
ServiceInstaller.StartService("MyServiceName");
//Stops the service
ServiceInstaller.StopService("MyServiceName");
//Check if service is installed
ServiceInstaller.ServiceIsInstalled("MyServiceName");
- 3 回答
- 0 关注
- 651 浏览
添加回答
举报