日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

Windows Service Wrapper:将程序注册为windows系统服务工具

發(fā)布時間:2024/9/19 windows 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Windows Service Wrapper:将程序注册为windows系统服务工具 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

前言

  • 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 包等注冊為 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可以試試這個下載地址:
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í)行程序在同一個目錄下。并將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>

注冊/卸載服務(wù)

以管理員身份運(yùn)行 CMD 命令窗口,輸入命令注冊為 windows 服務(wù)

MyApp_service.exe install # 注冊服務(wù) MyApp_service.exe uninstall # 卸載服務(wù)

啟動/停止服務(wù)

在 CMD 命令窗口,輸入命令啟動服務(wù),或我的電腦右鍵管理,在服務(wù)列表中啟動服務(wù)。

MyApp_service.exe start # 啟動服務(wù) MyApp_service.exe stop # 停止服務(wù) MyApp_service.exe restart # 重啟服務(wù) MyApp_service.exe status # 查看服務(wù)運(yùn)行狀態(tài)

另一組可以啟動/停止服務(wù)的命令

net start MyApp # 啟動服務(wù) net stop MyApp # 停止服務(wù) net stop MyApp && net start MyApp # 重啟服務(wù)

總結(jié)

以上是生活随笔為你收集整理的Windows Service Wrapper:将程序注册为windows系统服务工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。