SethAluma

AutoElevate.bat

Feb 23rd, 2022 (edited)
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.59 KB | None | 0 0
  1. @ECHO OFF
  2.  
  3. REM Test current admin level
  4. REG QUERY HKU\S-1-5-19\Environment >NUL 2>&1 && goto :START_PROCESS
  5.  
  6. REM Relaunch as admin if above fails
  7. powershell -NoProfile Start-Process -FilePath '%COMSPEC%' -ArgumentList '/c """%~0"""' -Verb RunAs 2>NUL
  8.  
  9. REM Error if re-launching as admin fails
  10. IF %ERRORLEVEL% GTR 0 (
  11.     echo =====================================================
  12.     echo This script needs to be executed as an administrator.
  13.     echo =====================================================
  14.     echo.
  15.     pause
  16. )
  17.  
  18. goto :EOF
  19.  
  20. :START_PROCESS
  21. REM Put your script here
  22.  
  23. :EOF
Add Comment
Please, Sign In to add comment