在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:ProjectItemsWorkSpaceGJ_GWZD_SYDynamicPlanService.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:ProjectItemsWorkSpaceGJ_GWZD_SYDynamicPlanService.exe" @echo. @pause