在服务程序的是设计窗体中点击右键“添加安装程序”,添加服务安装程序将serviceProcessInstaller1-Accout属性设为LocalSystem(默认是User)找到 Installutil.exe ,路径在:C:\Windows\Microsoft.NET\Framework\v4.0.30319将Installutil.exe 复制到服务代码的 bin\Debug下使用powershell,输入 .\InstallUtil.exe TestService.exe进行注册安装输入 .\InstallUtil.exe /u TestService.exe 进行卸载服务在任务管理器重进行启动 停止