Windows Service Wrapper:将程序注册为windows系统服务工具
前言
- wsw 2.3.0
Windows Service Wrapper
WinSW is an executable binary, which can be used to wrap and manage a custom process as a Windows service. Once you download the installation package, you can rename winsw.exe to any name, e.g. myService.exe.
Windows Service Wrapper 可以將 exe應(yīng)用、Java 的 jar 包等注冊(cè)為 windows 服務(wù)。
項(xiàng)目地址:
https://github.com/kohsuke/winsw
下載 wsw 2.3.0
github上的下載地址:
https://github.com/kohsuke/winsw/releases/tag/winsw-v2.3.0
連不上github可以試試這個(gè)下載地址:
http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/2.3.0/
下載WinSW.NET4.exe 和 sample-minimal.xml:
https://github.com/kohsuke/winsw/releases/download/winsw-v2.3.0/WinSW.NET4.exe
https://github.com/kohsuke/winsw/releases/download/winsw-v2.3.0/sample-minimal.xml
配置
以MyApp.exe的配置為例進(jìn)行說明。
把WinSW.NET4.exe和exe可執(zhí)行程序在同一個(gè)目錄下。并將WinSW.NET4.exe更改名稱,一般與exe可執(zhí)行程序名一致。例如,將WinSW.NET4.exe改為MyApp_service.exe。
把sample-minimal.xml改名為MyApp_service.xml。
更改 MyApp_service.xml 配置文件為下面這樣:
<configuration><!-- ID of the service. It should be unique across the Windows system--><id>MyApp</id><!-- Display name of the service --><name>MyApp</name><!-- Service description --><description>MyAppService (powered by WinSW)</description><!-- Path to the executable, which should be started --><executable>D:\MyApp\MyApp.exe</executable></configuration>注冊(cè)/卸載服務(wù)
以管理員身份運(yùn)行 CMD 命令窗口,輸入命令注冊(cè)為 windows 服務(wù)
MyApp_service.exe install # 注冊(cè)服務(wù) MyApp_service.exe uninstall # 卸載服務(wù)啟動(dòng)/停止服務(wù)
在 CMD 命令窗口,輸入命令啟動(dòng)服務(wù),或我的電腦右鍵管理,在服務(wù)列表中啟動(dòng)服務(wù)。
MyApp_service.exe start # 啟動(dòng)服務(wù) MyApp_service.exe stop # 停止服務(wù) MyApp_service.exe restart # 重啟服務(wù) MyApp_service.exe status # 查看服務(wù)運(yùn)行狀態(tài)另一組可以啟動(dòng)/停止服務(wù)的命令
net start MyApp # 啟動(dòng)服務(wù) net stop MyApp # 停止服務(wù) net stop MyApp && net start MyApp # 重啟服務(wù)總結(jié)
以上是生活随笔為你收集整理的Windows Service Wrapper:将程序注册为windows系统服务工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: excel查重公式
- 下一篇: 虎牙十大公会排名,白金公会或超跑公会你更