How to check for admin rights from a Windows batch file

Simple check for administrative permissions in a batch file:

REM Check for admin rights - net session must run as admin
net session >nul 2>&1
if %ErrorLevel% NEQ 0 (
    echo You must right-click and select "RUN AS ADMINISTRATOR" to run this script.
    echo.
    pause
    exit /B
)
Written on April 13, 2016