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應用、Java 的 jar 包等注冊為 windows 服務。
項目地址:
 https://github.com/kohsuke/winsw
下載 wsw 2.3.0
github上的下載地址:
 https://github.com/kohsuke/winsw/releases/tag/winsw-v2.3.0
連不上github可以試試這個下載地址:
 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的配置為例進行說明。
 把WinSW.NET4.exe和exe可執行程序在同一個目錄下。并將WinSW.NET4.exe更改名稱,一般與exe可執行程序名一致。例如,將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>注冊/卸載服務
以管理員身份運行 CMD 命令窗口,輸入命令注冊為 windows 服務
MyApp_service.exe install # 注冊服務 MyApp_service.exe uninstall # 卸載服務啟動/停止服務
在 CMD 命令窗口,輸入命令啟動服務,或我的電腦右鍵管理,在服務列表中啟動服務。
MyApp_service.exe start # 啟動服務 MyApp_service.exe stop # 停止服務 MyApp_service.exe restart # 重啟服務 MyApp_service.exe status # 查看服務運行狀態另一組可以啟動/停止服務的命令
net start MyApp # 啟動服務 net stop MyApp # 停止服務 net stop MyApp && net start MyApp # 重啟服務總結
以上是生活随笔為你收集整理的Windows Service Wrapper:将程序注册为windows系统服务工具的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: excel查重公式
- 下一篇: 虎牙十大公会排名,白金公会或超跑公会你更
