Wednesday, April 13, 2016

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.
    exit /B

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.