marioq

run_as_admin.cmd

Feb 6th, 2026 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.49 KB | None | 0 0
  1. @echo off
  2. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  3. if '%errorlevel%' NEQ '0' (
  4. set /a _ERROR+=%errorlevel%
  5. goto UACPrompt
  6. ) else ( goto gotAdmin )
  7. :UACPrompt
  8. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  9. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  10. "%temp%\getadmin.vbs"
  11. set /a _ERROR+=%errorlevel%
  12. exit /B  %_ERROR%
  13. :gotAdmin
  14. if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
Advertisement
Add Comment
Please, Sign In to add comment