0x0049

UAC

May 12th, 2015
353
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.73 KB | None | 0 0
  1. @echo off
  2. title UAC example for batch files
  3.  
  4. REM Check for permissions
  5. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  6.  
  7. REM If the error flag set, we do not have admin permissions.
  8. if '%errorlevel%' NEQ '0' (
  9.     echo Requesting administrative privileges...
  10.     goto UACPrompt
  11. ) else (goto GotAdmin)
  12.  
  13. REM Ask for admin permissions.
  14. :UACPrompt
  15.     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  16.     set params = %*:"="
  17.     echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
  18.  
  19.     "%temp%\getadmin.vbs"
  20.     del "%temp%\getadmin.vbs"
  21.     exit /B
  22.  
  23. REM Execute once admin permissions are granted.
  24. :GotAdmin
  25.     REM DO STUFF HERE
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment