1.下載
官網(wǎng)下載地址:https://github.com/winsw/winsw/releases
image.png
2.配置
將下載的exe文件放到一個文件夾中华烟,可以將文件重命名為自己想要的名字,然后創(chuàng)建一個xml文件,名稱必須與exe文件名相同。比如改名為my_jar_service.exe和my_jar_service.xml
<service>
<!-- 服務(wù)id,自行設(shè)置,與其他服務(wù)id不一致即可-->
<id>my_jar_service</id>
<!-- 服務(wù)名稱,也就是顯示在服務(wù)列表里的名稱 -->
<name>my_jar_service</name>
<!-- 服務(wù)的描述 -->
<description>定時任務(wù)調(diào)度</description>
<!-- 需要啟動的exe析苫,我這里直接寫了java,是因為配置了環(huán)境變量 -->
<executable>java</executable>
<!-- 要執(zhí)行命令 -->
<arguments>-jar "my_jar_service.jar"</arguments>
<priority>Normal</priority>
<stoptimeout>15 sec</stoptimeout>
<stopparentprocessfirst>false</stopparentprocessfirst>
<startmode>Automatic</startmode>
<waithint>15 sec</waithint>
<sleeptime>1 sec</sleeptime>
<log mode="append"></log>
</service>
3.安裝
配完成后穿扳,管理員身份啟動cmd衩侥,切換到my_jar_service.exe目錄,
安裝命令 my_jar_service.exe install
卸載命令 my_jar_service.exe uninstall
打開任務(wù)管理器查看服務(wù)