3

I know that you can get this option when you Shift+right-click, but I don't want to hold down Shift to see this option.

For instance, when Git installs on Windows, I don't have to Shift+right-click to see the "Open Git bash here", as it shows up just on right clicks as well.

Checking registry, I see that under HKEY_CLASSES_ROOT\Directory\shell\git_shell\command the default value "C:\Program Files\Git\git-bash.exe" "--cd=%1"

Under HKEY_CLASSES_ROOT\Directory\shell\Powershell\command the default value is: powershell.exe -noexit -command Set-Location '%V'.

So I figure that if I set the default entry under a custom location HKEY_CLASSES_ROOT\Directory\shell\PowershellHere\command to be powershell.exe -noexit -command Set-Location '%1', I would see the PowerShell option in the right-click menu, but it didn't work :(

What can I do?

4

4 Answers 4

3

Create a new registry key here:

HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellHere

(for the (Default) value you can leave it blank or add &PowershellHere and you could use right-click then the letter p as a hot key.)

Create another registry key here: HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellHere\command

Give the (Default) string the value of:

powershell.exe -noexit -command Set-Location -literalPath '%V'

or

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command Set-Location -literalPath '%V'

Alternately, you can hijack the existing key at: HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell by deleting the Extended and NoWorkingDirectory subkeys (however you will need to start regedit with administrative privileges.

10
  • This is exactly the file I used. PowerShell still doesn't show up in the menu options. Commented Jan 24, 2018 at 0:05
  • Just remove the information that doesn’t apply and delete the comments Commented Jan 24, 2018 at 0:48
  • This seems to work at least in terms of showing up the PowerShellHere option upon right click. When I actually tried to click on the menu option, it gave me an error saying that it doesn't have a command associated with it, but I think that was because it wants a sub-key named cmd and not command as you have in your answer. But I think there's a better way of doing this based on this answer: superuser.com/a/579691/298477 Commented Jan 24, 2018 at 0:51
  • I'll update your answer, for you to see what I mean! Give me 5 minutes. Commented Jan 24, 2018 at 0:51
  • Okay, updated your answer. See what you think of it. Basically, I think the values Extended and NoWorkingDirectory are under a different location than in Windows Vista, which the old answer was based on. The principle still applies (in terms of removing them). Also, I think you have to do some permission stuff? Commented Jan 24, 2018 at 0:58
1

Run this in Powershell to add Context Menus

This approach yields a right-click context menu that works both on folders, and in the background of folders to achieve a menu looking like this:

Powershell Context menu

  1. Run an Administrative Powershell prompt
  2. Paste the following commands:

reg delete "HKEY_CLASSES_ROOT\Directory\shell\PowershellConsoleHere" /f
reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellConsoleHere" /f
reg delete "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open" /f
reg delete "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas" /f


######## Add “Powershell Console Here” options to context menu

#### Right-Click Folder context menu

reg add "HKEY_CLASSES_ROOT\Directory\shell\PowershellConsoleHere" /v MUIVerb /t REG_SZ /d "Powershell" /f
reg add "HKEY_CLASSES_ROOT\Directory\shell\PowershellConsoleHere" /v Icon /t REG_SZ /d "powershell.exe" /f
reg add "HKEY_CLASSES_ROOT\Directory\shell\PowershellConsoleHere" /v ExtendedSubCommandsKey /t REG_SZ /d "Directory\Background\ContextMenus\MenuPowerShell" /f

#### Right-Click Background context menu

reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellConsoleHere" /v MUIVerb /t REG_SZ /d "Powershell" /f
reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellConsoleHere" /v Icon /t REG_SZ /d "powershell.exe" /f
reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellConsoleHere" /v ExtendedSubCommandsKey /t REG_SZ /d "Directory\Background\ContextMenus\MenuPowerShell" /f

### Create sub-context menu options
##  Sub-context menu option: Console
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open" /v MUIVerb /t REG_SZ /d "Console" /f
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open" /v Icon /t REG_SZ /d "powershell.exe" /f

# Set default key value "(Default)"
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open\command" /f /ve /d "powershell.exe -noexit -command Set-Location '%V'"

##  Sub-context menu option: Elevated Console
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas" /v MUIVerb /t REG_SZ /d "Elevated Console" /f
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas" /v Icon /t REG_SZ /d "powershell.exe" /f
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas" /v HasLUAShield /t REG_SZ /d "" /f

# Set default key value "(Default)"
reg add "HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas\command" /f /ve /d "powershell.exe -noexit -command Set-Location '%V'"

This is based on the MSDN blog article Enhancing the “Open Command Prompt here” Context Menu experience

1

Here is the reg file I use to add Powershell commands to the Background menu in Windows 10;

Windows Registry Editor Version 5.00

;Add_Open_Powershell_to_Context_Menu.reg

;Right-Click Background only

[HKEY_CLASSES_ROOT\Directory\Background\shell\02MenuPowerShell]
"MUIVerb"="PowerShell Prompts"
"Icon"="powershell.exe"
"ExtendedSubCommandsKey"="Directory\\Background\\ContextMenus\\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\Background\shell\02MenuPowerShell]
"MUIVerb"="PowerShell Prompts"
"Icon"="powershell.exe"
"ExtendedSubCommandsKey"="Directory\\Background\\ContextMenus\\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open\command]
@="powershell.exe -noexit -command Set-Location '%V'"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas]
"MUIVerb"="PowerShell Elevated"
"Icon"="powershell.exe"
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas\command]
@="powershell.exe -noexit -command Set-Location '%V'"
2
  • The first two [HKEY_CLASSES_ROOT\Directory\Background\shell\02MenuPowerShell] sections are duplicated... Commented Jun 4, 2019 at 20:45
  • This is good. It creates a right-click sub-menu with an option for a regular console, and an elevated console. But it doesn't work on clicking folders themselves (only the background when in a folder in Explorer). Commented Jun 4, 2019 at 20:58
0

You can use this awesome library

https://github.com/kerol2r20/Windows-terminal-context-menu

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.