New
#21
You won't regret doing so.
Im glad you found that command line useful, Usernamewastake.
I've since shortened the 'prompt for Admin rights' line, and have also created a faster version of the one-liner, one which uses VBScript, I will share here for anyone to use:
(add these lines just under the "@echo off" in your batch files)
Using PowerShell
Same line as seen in post #18, only shorter. This is currently the shortest known method for promoting a UAC dialogue in batch. Though there's small caveat: red text can be seen briefly on the Cmd screen upon a user declining the UAC dialogue.Code:net sess>NUL 2>&1||(powershell saps '%0'-Verb RunAs&exit)Below is the same as the above, but no red text will appear upon the user declining the UAC dialogue.Code:net sess>NUL 2>&1||(powershell try{saps '%0'-Verb RunAs}catch{}&exit)
Using VBScript
About 4 times faster than the PowerShell method. Though very briefly makes use of a temporary file.Code:net sess>NUL 2>&1||(echo.CreateObject^("Shell.Application"^).ShellExecute"%~0",,,"RunAs",1 >"%TEMP%\%~nx0.vbs"&WScript "%TEMP%\%~nx0.vbs"&del "%TEMP%\%~nx0.vbs"&exit)