以超级管理员方式直接运行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 %2ver|find "5.">nul&&goto :stmshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof:stcopy "%~0" "%windir%\system32\" # 以上代码是以超级管理员方式运行sc create DynamicPlanService binPath= "D:\ProjectItems\WorkSpace\GJ_GWZD_SY\DynamicPlanService.exe"sc config DynamicPlanService start= AUTOsc description DynamicPlanService "¶¯Ì¬ÅŲú·þÎñ,¸ù¾ÝÿÈÕÖ´ÐÐÇé¿ö½øÐÐÖØÐÂ×Ô¶¯¼ÆË㡣ÿÌìµÄÁãʱÔÚºǫ́×Ô¶¯Ö´ÐÐ,½«¼ÆËã³ö¹¤ÐòµÄÈ«²¿ÐÅÏ¢£¬ÌرðÊǾ«È·µÄͶÁϺͲú³öµÄʱ¼ä"net start DynamicPlanService @echo.@pause