Code
:: How to Add 'Run as administrator' to PS1 File Context Menu in Windows 10
@Echo Off
net sess>nul 2>&1||(powershell start cmd -ArgumentList """/c %~0""" -verb Runas & exit)
Cls & Mode CON LINES=11 COLS=75 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo.
Echo Add Run as administrator to PS1 File Context Menu (Y/N)?
Echo.
Echo.
Echo.
Set /p input= RESPONSE:
If /i Not %input%==Y (Goto :_Ex) Else (Goto :_Start)
:_Ex
If /i Not %input%==N (Goto :EOF) Else (Goto :_RegRestore)
:_Start
Reg.exe delete "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /f > Nul
Reg.exe add "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /v "HasLUAShield" /t REG_SZ /d "" /f > Nul
Reg.exe add "HKCR\Microsoft.PowerShellScript.1\Shell\runas\command" /ve /t REG_SZ /d "powershell \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%%1'\"" /f > Nul
Cls & Mode CON LINES=11 COLS=40 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo.
Echo Adding Context Menu
Echo.
Echo.
Echo.
Ping -n 6 localhost >Nul
Exit
:_RegRestore
Reg.exe delete "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /f > Nul
Cls & Mode CON LINES=11 COLS=40 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo.
Echo Removing Context Menu
Echo.
Echo.
Echo.
Ping -n 6 localhost >Nul
Exit
