1、创建服务,命名为Create.bat
@echo.Service create...... set a="%~dp0programName.exe" @echo off @sc create ***(serverName)binPath= %a%
@sc config ***(serverName) start= AUTO
@echo off @echo.create end! @pause
2、启动服务,命名为Start.bat
@echo.Service starting...... @echo off @net start ***(serverName)
@echo off @echo.start end! @pause
3、停止服务,命名为Stop.bat
@echo.Service Close @echo off @net stop ***(serverName)
@echo off @echo.close end! @pause
4、删除服务,命名为Delete.bat
@echo.Services delete...... @echo off @sc delete ***(serverName)
@echo off @echo.delete end! @pause
以上是四个批处理文件,启动服务的步骤为create,start。