欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

命令行判断当前是否以管理员方式运行

程序员文章站 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
)