在windows 平臺下,服務的安裝與卸載可經過bat 腳本命令來完成,同時可編輯服務的描述,具體代碼以下:shell
1.服務的安裝DynamicPlanService_installer.bat:windows
@echo =============================== 動態排產服務 ============================= @echo ============================== Version:V1.0.0 ============================ @echo =========================== Created:2018-12-24 =========================== @echo ======================= ServiceName:DynamicPlanService ====================== @echo ================ Copyright: @2017-2019 Will All Rights Reserved. ============= @echo. @echo. @echo. @echo off %1 %2 ver|find "5.">nul&&goto :st mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof :st copy "%~0" "%windir%\system32\" sc create DynamicPlanService binPath= "D:\ProjectItems\WorkSpace\GJ_GWZD_SY\DynamicPlanService.exe" sc config DynamicPlanService start= AUTO sc description DynamicPlanService "動態排產服務,根據每日執行狀況進行從新自動計算。天天的零時在後臺自動執行,將計算出工序的所有信息,特別是精確的投料和產出的時間" net start DynamicPlanService @echo. @pause
2. 服務卸載 DynamicPlanService_Uninstaller.batapp
@echo =============================== 動態排產服務 ============================= @echo ============================== Version£ºV1.0.0 ============================ @echo =========================== Created£º2018-12-24 =========================== @echo ======================= ServiceName£ºDynamicPlanService ====================== @echo ================ Copyright: @2017-2019 Will All Rights Reserved. ============= @echo. @echo. @echo. @echo off %1 %2 ver|find "5.">nul&&goto :st mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof :st copy "%~0" "%windir%\system32\" net stop DynamicPlanService sc delete DynamicPlanService binPath= "D:\ProjectItems\WorkSpace\GJ_GWZD_SY\DynamicPlanService.exe" @echo. @pause