windows安装exe为系统服务

1.使用window系统中附带的InstallUtil.exe,路径地址:C:\Windows\Microsoft.NET\Framework64\v4.0.30319
可以安装和卸装.net开发的windows服务,脚本如下


-------------install.bat-------------
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe  D:\service\Test.exe
pause


-------------uninstall.bat----------
 C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /u  D:\service\Test.exe
 pause


2.使用cmd命令行,可以安装和卸装windows全部可执行文件,脚本如下


------------install-----------------
sc create ServiceName start= auto binpath= D:\service\Test.exe


------------uninstall---------------
sc delete ServiceName


------------start-------------------
net start ServiceName


------------stop--------------------
net stop ServiceName


3.使用第三方工具prunsrv.exe,可以安装windows全部可执行文件


-----------config-----------------
1.新建系统变量ViolationHigh462,值为服务名称
2.新建系统变量ViolationHigh462home,值为exe的目录
-----------install-----------------
prunsrv.exe "//IS//%ViolationHigh462%"^
        --DisplayName="%ViolationHigh462%"^
        --Description="%ViolationHigh462%"^
        --Startup=auto --StartMode=exe^
        --StartPath=%ViolationHigh462home%^
        --StartImage=%ViolationHigh462home%\ViolationHigh462.exe^
        --LogPath=%ViolationHigh462home%\logs --LogPrefix=ViolationHigh462-wrapper^
        --PidFile=ViolationHigh462.pid --LogLevel=Info --StdOutput=auto --StdError=auto
pause


--------uninstall-----------------
prunsrv.exe //DS//%ViolationHigh462%
pause

你可能感兴趣的:(工具和技巧)