Determine whether the current command line mode Run as administrator

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/frozleaf/article/details/91383146
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
)

 

Guess you like

Origin blog.csdn.net/frozleaf/article/details/91383146