Loading

windows服务开发注意事项

1、新建window服务

 

2、Service1.cs 右键,添加安装程序

serviceInstaller1的DisplayName改成Nms开头的,方便从windows服务列表中查找

serviceProcessInstaller1的Account要修改成LocalSystem

 

3、环境变量配置.net路径

如果不是x64版本,复制这个地址:

C:\Windows\\Framework\v4.0.30319

如果是x64版本,复制这个地址:

C:\Windows\\Framework64\v4.0.30319

 cmd输入这个命令查看一下【InstallUtil】测试是否配置成功,

 

4、管理员安装卸载服务

进入管理员cmd   安装:

InstallUtil D:\项目演示临时保存\MyDemoService\MyDemoService\bin\Debug\MyDemoService.exe

或者卸载:

InstallUtil   \u  D:\项目演示临时保存\MyDemoService\MyDemoService\bin\Debug\MyDemoService.exe

posted @ 2025-03-17 17:52  shihao316558512  阅读(6)  评论(0)    收藏  举报