C# 安装部署Windows服务脚本

@echo off
Installutil.exe 程序目录 F:	estTestWindows.exe 服务程序目录
@sc start "服务名称"
@sc config "服务名称" start= 启动方式:AUTO
@echo off
@echo 服务安装并启动完成
pause

示例:

@echo off
C:WindowsMicrosoft.NETFrameworkv4.0.30319InstallUtil.exe F:	estTestWindows.exe
@sc start "Test Windows"
@sc config "TestWindows" start= AUTO
@echo off
@echo 服务安装并启动完成
pause

 bat文件代码:

安装服务代码:
 
sc delete 服务名称
 
sc create WindowsServiceTest start= auto binPath= D:wwwDebug服务名称.exe
 
sc description 服务名称 "BY Eadily"
 
pause
 
 
卸载服务代码:
 
net stop 服务名称
 
sc delete 服务名称
原文地址:https://www.cnblogs.com/SuperMetalMax/p/6206937.html