Windows服务安装与卸载,使用到了InstallUtil.exe
安装:
c:
cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
InstallUtil.exe "D:\OrderService.exe"
卸载:
c:
cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
InstallUtil.exe /u "D:\OrderService.exe"
更加高级的,把BAT文件放项目目录下,与.EXE文件平级,无须知道.NET Framework位置
安装:
@echo off
C:
cd C:\Windows\Microsoft.NET\Framework64\v4.*
.\installutil %~dp0OrderService.exe
net start OrderService
pause