fbpx

Best Way to Open PowerShell in Windows Explorer? Add In Windows 10 Context Menu

When you Shift+click a folder in Windows, the option to “Open PowerShell window here” is already present. However, PowerShell has a more robust feature set, particularly if you use scripting to automate anything. 

Open PowerShell in Windows Explorer? Add In Windows 10 Context Menu

If PowerShell is what you prefer, you must either launch PowerShell and then navigate to the folder or use the command from the File Explorer menu. Instead, add the option to the same context menu to Open the PowerShell window here.

Methods To Open Powershell In Windows File Explorer

  1. Open PowerShell Window Via The Address Bar
  2. Open PowerShell Via The File Menu
  3. Create Custom PowerShell Context Menu
  4. PowerShell Custom Menu (Open Powershell Window Here)

1. Open PowerShell Window Via The Address Bar

The File Explorer window contains a section at the top that lets you launch programs as though you were at a command line. By holding CTRL, you can launch PowerShell from this address bar.

Windows PowerShell
  • You will be in an administrative PowerShell and Command Prompt prompt if you are logged in as the Administrator.

2. Open PowerShell Via The File Menu

You can utilize the file menu to launch PowerShell in File Explorer. You could use the mouse or keyboard shortcut to access the file menu. You can access the file menu by using the ALT key.

  • Hold down the ALT key.
  • Hit the F key. The file menu will then be shown.
Open Windows PowerShell.
  • Hit the S key. This choice expands a different sub-menu and selects Open Windows PowerShell.
Open Windows PowerShell.
  • Press the R key to finish. The current directory is where PowerShell will open.
  • Use A instead of R to launch PowerShell as an administrator if necessary.

3. Create Custom PowerShell Context Menu

The menu that appears when you right-click on an item in Windows is known as a context menu. When you right-click inside of a folder, you may instantly open a PowerShell window by using a carefully placed Windows registry value to create a custom context menu item.

custom context menu option
  • You can access the context menu option below by right-clicking in a folder while holding down the SHIFT key.
custom context menu option
  • Let’s create a custom context menu option that enables a Shift-free PowerShell window opening.
  • You need to generate a few distinct Windows registry entries and values in order to construct a custom context menu item. 
PathNameValue
HKCR:\Directory\shell\powershellmenu(Default)Open PowerShell Here
HKCR:\Directory\shell\runas (Default)Open PowerShell Here as Administrator
HKCR:\Directory\shell\powershellmenu\command(Default)C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command Set-Location -LiteralPath ‘%L’
HKCR:\Directory\shell\runasHasLUAShield This adds a built-in icon for elevated prompts

The aforementioned keys and values can be created manually or with the aid of a PowerShell script.

$Menu = 'Open PowerShell Here'
 $Command = "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
 $RunAsMenu = 'Open PowerShell Here as Administrator'

You need to create HKCR.
New-PSDrive -PSProvider Registry -Root HKEY_CLASSES_ROOT -Name HKCR

Now create the keys and values (non-admin)
New-Item -Path HKCR:\Directory\shell -Name 'powershellmenu' -Force |
     Set-ItemProperty -Name '(Default)' -Value $Menu
 New-Item -Path HKCR:\Directory\shell\powershellmenu\command -Force |
     Set-ItemProperty -Name '(Default)' -Value $Command

 Now create the keys and values (admin)
 New-Item -Path HKCR:\Directory\shell -Name 'runas' -Force |
     Set-ItemProperty -Name '(Default)' -Value $RunAsMenu


     New-ItemProperty -Path HKCR:\Directory\shell\runas\ -Name HasLUAShield -Value ''
 New-Item -Path HKCR:\Directory\shell\runas\command -Force |
     Set-ItemProperty -Name '(Default)' -Value $Command

4. PowerShell Custom Menu (Open Powershell Window Here)

Within File Explorer, right-click any folder. The new context menu entry for Open PowerShell Here that you made should now appear. 

There will be a new context menu item called Open PowerShell Here.

PowerShell Custom Menu