写完一个Windows Service 怎样将它部署到你的服务中呢,也就是让它显示在Services.msc的服务列表中,并可以在使用的时候去启动。
- 首先将编译好的Service exe程序与InstallUtil.exe执行程序放在一起。
- 编写Install.bat如下:
@echo off
InstallUtil.exe ServiceTest.exe
Rem Net Start ServiceTest
sc config ServiceTest start= manual
@pause
然后执行该批处理程序就可以在服务中看到你所编写的Windows Service。这里的ServiceTest.exe是我测试用的服务。 - 注销服务,可以编写Uninstall.bat
@echo off
InstallUtil.exe /u ServiceTest.exe
@pause
然后执行,就可以注销掉此服务。