加入头部可自动获取
1 2 3 4 5 |
@echo off %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit fltmc>nul&&(echo 已获得管理员权限)||(echo 未获得管理员权限) pause exit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
@echo off setlocal set uac=~uac_permission_tmp_%random% md "%SystemRoot%\system32\%uac%" 2>nul if %errorlevel%==0 ( rd "%SystemRoot%\system32\%uac%" >nul 2>nul ) else ( echo set uac = CreateObject^("Shell.Application"^)>"%temp%\%uac%.vbs" echo uac.ShellExecute "%~s0","","","runas",1 >>"%temp%\%uac%.vbs" echo WScript.Quit >>"%temp%\%uac%.vbs" "%temp%\%uac%.vbs" /f del /f /q "%temp%\%uac%.vbs" & exit ) endlocal set TempFile_Name=%SystemRoot%\System32\BatTestUACin_SysRt%Random%.batemp ( echo "BAT Test UAC in Temp" >%TempFile_Name% ) 1>nul 2>nul if exist %TempFile_Name% ( del %TempFile_Name% 1>nul 2>nul echo 已获得管理员权限 ) else ( echo 未获得管理员权限 ) pause exit |
发表回复