Advertisement
metalx1000

Have a Windows Batch File Request Admin Privileges

Oct 29th, 2013
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2.  
  3. @echo off
  4.  
  5. :: Get ADMIN Privs
  6. :-------------------------------------
  7. mkdir "%windir%\BatchGotAdmin"
  8. if '%errorlevel%' == '0' (
  9. rmdir "%windir%\BatchGotAdmin" & goto gotAdmin
  10. ) else ( goto UACPrompt )
  11.  
  12. :UACPrompt
  13. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  14. echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  15.  
  16. "%temp%\getadmin.vbs"
  17. exit /B
  18.  
  19. :gotAdmin
  20. if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  21. pushd "%CD%"
  22. CD /D "%~dp0"
  23. :-------------------------------------
  24. :: End Get ADMIN Privs
  25.  
  26. <YOUR BATCH SCRIPT HERE>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement