The folder background context menu is controlled by the HKEY_CLASSES_ROOT\Directory\background\shell
registry key. For example, the "Open with Visual Studio" entry is controlled by the AnyCode
subkey.
Command Prompt and PowerShell
Windows 10 already has entries for cmd.exe
and powershell.exe
, but they are hidden by default. You can show the PowerShell one by holding the Shift key while right-clicking the background of the folder window. Command Prompt is hidden when PowerShell is installed using the HideBasedOnVelocityId
value.
To always show Command Prompt and PowerShell in the folder background context menu, without needing to hold Shift:
- Give yourself permissions to modify the
shell
key.
- Right-click the key in Registry Editor.
- Choose Permissions > Advanced.
- Change the Owner to
Administrators
, and check both "Replace owner on subcontainers and objects" and "Replace all child object permissions entries with inheritable permission entries from this object".
- Click OK to close the Permissions dialog boxes.
- In both the
cmd
and PowerShell
subkeys, delete or rename the Extended
, HideBasedOnVelocityId
, and ShowBasedOnVelocityId
values.
Now when you right-click on the background of a folder, you should see "Open command window here" and "Open PowerShell window here" in the context menu.
New entries
To add new entries to the folder background context menu, you can create new keys in the HKEY_CLASSES_ROOT\Directory\background\shell
registry key.
- The name of the new key can be any unique name you want, it doesn't appear in the UI.
- The text label of the context menu entry is controlled by the
(Default)
value in the key.
- The optional icon of the entry is controlled by the
Icon
string value in the subkey. It can be the filename of an ICO file, or a PE file (DLL/EXE) with an optional numeric ID separated by a comma. The index can be non-negative for the 0-based index of the icon in the PE file, or negative for the resource ID.
- The program and arguments to run when you click the entry are controlled by the
(Default)
value of the command
subkey. It uses the %V
placeholder variable to represent the current directory.
MinGW Bash example
I have MinGW Bash installed as part of Git for Windows. Here is a .reg
file that adds it to my folder background context menu. Your installation directory will probably differ.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]
@="Open in Bash"
"Icon"="C:\\Programs\\Development\\Git\\mingw64\\share\\git\\git-for-windows.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
@="\"C:\\Programs\\Development\\Git\\bin\\bash.exe\""
This opens Bash in the given folder, even thought the command does not use %V
, because Windows starts the process with the folder as the new process's working directory by default (unless a NoWorkingDirectory
value is present in the key).
I no longer have Cygwin installed, but a menu entry for its Bash can most likely be added in a similar manner.
Windows 11 has an "Open in Terminal" entry always visible in the equivalent menu, although it is more challenging to customize.