Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @REM Request administrative privileges
- @REM https://sites.google.com/site/eneerge/scripts/batchgotadmin
- :: BatchGotAdmin
- :-------------------------------------
- @REM --> Check for permissions
- @>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
- @REM --> If error flag set, we do not have admin.
- @if '%errorlevel%' NEQ '0' (
- @goto UACPrompt
- ) else ( @goto gotAdmin )
- :UACPrompt
- @echo Dim execResult> "%temp%\getadmin.vbs"
- @echo Set UAC = CreateObject^("Shell.Application"^)>> "%temp%\getadmin.vbs"
- @echo execResult = UAC.ShellExecute^("%~s0", "", "", "runas", 1^)>> "%temp%\getadmin.vbs"
- @echo WScript.Quit(execResult)>> "%temp%\getadmin.vbs"
- @"%temp%\getadmin.vbs"
- @exit /B
- :gotAdmin
- @if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
- @pushd "%CD%"
- @CD /D "%~dp0"
- :--------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement