Skip to content

Instantly share code, notes, and snippets.

@maciakl
Last active January 8, 2024 00:11
Show Gist options
  • Save maciakl/f30629d1a606030e55855842447472c5 to your computer and use it in GitHub Desktop.
Save maciakl/f30629d1a606030e55855842447472c5 to your computer and use it in GitHub Desktop.
If your batch file needs to run as Administrator, put this at the top of your script. It will initiate a UAC prompt and run the rest of the script in elevated mode.
if "%1" == "elevated" goto start
powershell -command "Start-Process %~nx0 elevated -Verb runas"
goto :EOF
:start
rem your code goes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment