在windows 平台下,服務的安裝與卸載可通過bat 腳本命令來完成,同時可編輯服務的描述,具體代碼如下:
1.服務的安裝DynamicPlanService_installer.bat:
@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.bat
@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
