以超級管理員方式直接運行bat 腳本文件,直接上腳本代碼,如下是以一個服務的安裝爲例子shell
@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