Now I get why Microsoft did this. It’s probably a security measure to prevent you from accidentally hosing your system by running a bunch of scripts in the Administrator context. It’s certainly not a feature I’d want “Joe User” to have access to. Still us more “advanced” users might want to have this menu item present purely to speed up our script testing process. So to solve this little dilemma for myself I put together two Batch scripts (HA, Ha, yes I’m using Batch to ultimately eliminate Batch) to add the right-click options back in for .PS1 and .VBS files. The scripts I wrote are posted below. Note that with the .VBS script you have two options! One uses CSCRIPT.EXE and the other uses WSCRIPT.EXE. If you don’t know the difference then don’t use the scripts. They also come with no warranties! Use at your own risk!
Add Right-click “Run as administrator” for .PS1 files (PowerShell):
@ECHO OFF & CLS
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TITLE Enable right-click 'Run as Admin' for PowerShell for Windows 7 or Later
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Purpose: Add Windows context menu item.
:: Version: 2.1
:: Author: ZeusABJ
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Display status message:
ECHO.
ECHO Enabling right-click 'Run as Admin' for PowerShell for Windows 7 or Later...
ECHO.
:: Add value for UAC shield icon:
REG ADD "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /v HasLUAShield /t REG_SZ /d "" /f
:: Add value to create context menu item:
REG ADD "HKCR\Microsoft.PowerShellScript.1\Shell\runas\command" /ve /t REG_EXPAND_SZ /d "\"%%SYSTEMROOT%%\System32\WindowsPowerShell\v1.0\powershell.exe\" -executionpolicy bypass -nologo -file \"%%1\"" /f
:: Display completion notice:
ECHO.
ECHO Done!
:: Delay for processing:
PING 127.0.0.1 -n 3 > NUL
:: Pause to view results:
:: ECHO.
:: PAUSE
EXIT
Remove Right-click “Run as administrator” for .PS1 files (PowerShell):
@ECHO OFF & CLS
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TITLE Disable right-click 'Run as Admin' for PowerShell for Windows 7 or Later
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Purpose: Remove Windows context menu item.
:: Version: 2.1
:: Author: ZeusABJ
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Display status message:
ECHO.
ECHO Disabling right-click 'Run as Admin' for PowerShell for Windows 7 or Later...
ECHO.
:: Remove custom 'runas' registry entry:
REG DELETE "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /f
:: Display completion notice:
ECHO.
ECHO Done!
:: Delay for processing:
PING 127.0.0.1 -n 3 > NUL
:: Pause to view results:
:: ECHO.
:: PAUSE
EXIT
Add Right-click “Run as administrator” for .VBS files (VBScript - WSCRIPT.EXE):
@ECHO OFF & CLS
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TITLE Enable right-click 'Run as Admin' for VBS for Windows 7 or Later (WSCRIPT)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Purpose: Add Windows context menu item.
:: Version: 2.0
:: Author: ZeusABJ
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Display status message:
ECHO Enabling right-click 'Run as Admin' for VBS for Windows 7 or Later (WSCRIPT)...
ECHO.
:: Add value for UAC shield icon:
REG ADD "HKCR\VBSFile\Shell\runas" /v HasLUAShield /t REG_SZ /d "" /f
:: Add value to create context menu item:
REG ADD "HKCR\VBSFile\Shell\runas\Command" /ve /t REG_EXPAND_SZ /d "\"%%SYSTEMROOT%%\System32\wscript.exe\" \"%%1\" %%*" /f
:: Display completion notice:
ECHO.
ECHO Done!
:: Delay for processing:
PING 127.0.0.1 -n 3 > NUL
:: Pause to view results:
:: ECHO.
:: PAUSE
EXIT
Add Right-click “Run as administrator” for .VBS files (VBScript - CSCRIPT.EXE):
@ECHO OFF & CLS
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TITLE Enable right-click 'Run as Admin' for VBS for Windows 7 or Later (CSCRIPT)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Purpose: Add Windows context menu item.
:: Version: 2.1
:: Author: ZeusABJ
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Display status message:
ECHO.
ECHO Enabling right-click 'Run as Admin' for VBS for Windows 7 or Later (CSCRIPT)...
ECHO.
:: Add value for UAC shield icon:
REG ADD "HKCR\VBSFile\Shell\runas" /v HasLUAShield /t REG_SZ /d "" /f
:: Add value to create context menu item:
REG ADD "HKCR\VBSFile\Shell\runas\Command" /ve /t REG_EXPAND_SZ /d "\"%%SYSTEMROOT%%\System32\cscript.exe\" \"%%1\" %%*" /f
:: Display completion notice:
ECHO.
ECHO Done!
:: Delay for processing:
PING 127.0.0.1 -n 3 > NUL
:: Pause to view results:
:: ECHO.
:: PAUSE
EXIT
Remove Right-click “Run as administrator” for .VBS files (VBScript):
@ECHO OFF & CLS
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TITLE Disable right-click 'Run as Admin' for VBS for Windows 7 or Later
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Purpose: Remove Windows context menu item.
:: Version: 2.1
:: Author: ZeusABJ
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Display status message:
ECHO.
ECHO Disabling right-click 'Run as Administrator' for VBS for Windows 7 or Later...
ECHO.
:: Remove custom 'runas' registry entry:
REG DELETE "HKCR\VBSFile\Shell\runas" /f
:: Display completion notice:
ECHO.
ECHO Done!
:: Delay for processing:
PING 127.0.0.1 -n 3 > NUL
:: Pause to view results:
:: ECHO.
:: PAUSE
EXIT