命令行判断当前是否以管理员方式运行
程序员文章站
2022-05-10 09:39:39
...
rem Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
rem Success: Administrative permissions confirmed.
) else (
echo ERROR: Administrative permissions required ^!
echo Patching not performed ^!
echo.
echo INFO: Run AutoPatch.cmd as ADMIN ^!
echo.
pause
exit
)