Skip to content

Instantly share code, notes, and snippets.

@OnCloud125252
Last active January 20, 2024 02:23
Show Gist options
  • Save OnCloud125252/14c7067b40c106cb179e0bf78555db2b to your computer and use it in GitHub Desktop.
Save OnCloud125252/14c7067b40c106cb179e0bf78555db2b to your computer and use it in GitHub Desktop.
Run Batch As Administrator
TITLE Asking for administrator access
MODE CON COLS=37 LINES=3
COLOR F0
ECHO :::::::::::::::::::::::::::::::::::::
ECHO :: Requesting administrator access ::
ECHO :::::::::::::::::::::::::::::::::::::
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && ""%~s0"" %Apply%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
COLOR
CLS
// The following command will be run as administrator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment