以超级管理员方式直接运行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