Created
July 2, 2018 07:38
-
-
Save thushan/96c98f861a16b98626ed64f5e5966de2 to your computer and use it in GitHub Desktop.
Auto-Elevate Batch Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM Credit: https://stackoverflow.com/a/25756858 | |
REM Save current directory which lets us come back to our working directory | |
pushd %~dp0 | |
net file 1>nul 2>nul && goto :run || powershell -ex unrestricted -Command "Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~fnx0 %*'" | |
goto :eof | |
:run | |
REM Run any elevated tasks here | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment