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

示例:

@echo off
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe F:\test\TestWindows.exe
@sc start "Test Windows"
@sc config "TestWindows" start= AUTO
@echo off
@echo 服务安装并启动完成
pause

 bat文件代码:

安装服务代码:
 
sc delete 服务名称
 
sc create WindowsServiceTest start= auto binPath= D:\www\Debug\服务名称.exe
 
sc description 服务名称 "BY Eadily"
 
pause
 
 
卸载服务代码:
 
net stop 服务名称
 
sc delete 服务名称

 

相关文章:

  • 2021-07-17
  • 2021-05-03
  • 2021-08-14
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-08-01
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2021-11-20
  • 2022-01-28
  • 2021-10-17
  • 2021-11-01
  • 2021-04-09
相关资源
相似解决方案