Open Elevated PowerShell Prompt Here From Right-Click Context Menu Instead Of Command Prompt Here As Administrator In Windows 10 Creators Edition

#Open Elevated PowerShell Prompt Here From Right-Click Context Menu Instead Of Command Prompt Here As Administrator In Windows 10 Creators Edition

#Run these commands to enable an elevated Elevated PowerShell Prompt Here also known as PowerShell Here as Administrator when right clicking on a folder in Windows Explorer. These commands all work in both PowerShell and PowerShell Direct.

#Just the code:

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Verbose -Force|ft -a
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name '(default)' -Value 'Elevated PowerShell Prompt Here' -Verbose -PassThru|fl
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name Icon -Value 'C:\\Windows\\System32\\imageres.dll,-78' -Verbose -PassThru|fl
New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -Verbose -Force|ft -a
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command|Set-ItemProperty -Name '(default)' -Value '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoExit cd "%1"' -Verbose -PassThru|fl

#The Long Story…

#HKCR: does not work in this example and you do not need to mount first. This method accesses the registry directly. Many instructions say to use New-PSDrive to mount HKCR: first and use that convention to access it to do many things but none of that is needed.

#Get-PSDrive will show you what is mounted.

Get-PSDrive

#▲As you can see there is no HKCR:

#Moving on…

#If done properly launching Elevated PowerShell Prompt Here will trigger a UAC prompt. This is normal and good. Create all the keys and values by typing the following commands in order:

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Verbose -Force|ft -a

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name '(default)' -Value 'Elevated PowerShell Prompt Here' -Verbose -PassThru|fl

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name Icon -Value 'C:\\Windows\\System32\\imageres.dll,-78' -Verbose -PassThru|fl

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -Verbose -Force|ft -a

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command|Set-ItemProperty -Name '(default)' -Value '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoExit cd "%1"' -Verbose -PassThru|fl

#This works when right-clicking only on folders in Windows Explorer and not drives or drive letters.

#Create the User’s file folder (from the Desktop Experience feature) on the Desktop of all new and current users

#Run this to create the User’s file folder (from the Desktop Experience Feature) on the Desktop of all new and current users. After that you will always have a folder nearby to single right-click on to launch an Elevated PowerShell Prompt Here session.

Get-ItemProperty Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel|Set-ItemProperty -Name '{59031a47-3f72-44a7-89c5-5595fe6b30ee}' -Value 0 #Show User Data Folder icon on all Desktops - Applies to Local Machine / All Users

Leave a Reply