:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 自动添加批处理文件管理员权限 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::@echo offCLSECHO.ECHO ================================ECHO 获取批处理文件管理员权限ECHO ================================:init
setlocal DisableDelayedExpansionset "batchPath=%~0"for %%k in (%0) do set batchName=%%~nkset "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"setlocal EnableDelayedExpansion:checkPrivileges
NET FILE 1>NUL 2>NULif '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ):getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)ECHO.ECHO ********************************ECHO 请求 UAC 权限批准……ECHO ********************************ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"ECHO Next >> "%vbsGetPrivileges%"ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%""%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*exit /B:gotPrivileges
setlocal & pushd .cd /d %~dp0if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1):::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 以下为需要运行的批处理文件代码 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::rem 以下可修改为你需要的bat命令ECHO 欢迎使用!ECHO.pause