REM Test if AdminCALL NET SESSION >nul 2>&1IF NOT %ERRORLEVEL% == 0 ( rem Start batch again with UAC echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /B rem Program will now start again automatically with admin rights! rem pause goto :eof) echo Started with Admin privilliges... REM Here you can enter your custom codeREM In this example, `hosts` file is started with admin rights CD C:\Windows\System32\drivers\etc notepad hosts