Skip to main content

Example: Add A Command To The Folder Context Menu

This worked example shows a complete edit from start to finish. It adds an Open command prompt here entry to the right-click menu of folders, which opens a command prompt already pointed at the selected folder.

It uses the skills from the rest of this guide: navigating, creating keys, and editing the default value.

Back up first

This example changes HKEY_CLASSES_ROOT, which affects all users. Export the HKEY_CLASSES_ROOT\Folder\shell key before you start, so you can restore it. See Export.

Steps

  1. In the key tree, navigate to:

    HKEY_CLASSES_ROOT\Folder\shell
  2. Create a new key under shell and name it, for example, OpenCmd. Its name is internal; see the next step for the visible label. See Create Keys.

  3. Select the new OpenCmd key and edit its default value ((Default)) to the text you want to appear in the context menu, for example:

    Open command prompt here
  4. Under OpenCmd, create another key named command.

  5. Select command and set its default value to the command line to run:

    "C:\Windows\System32\cmd.exe" /k pushd "%V"

    %V is replaced with the path of the folder you right-clicked.

  6. Test it: right-click a folder in Windows Explorer. The Open command prompt here entry now appears, and choosing it opens a command prompt in that folder.

The Same Change As A .reg File

You can achieve the same result by importing this file:

open-cmd-here.reg
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\OpenCmd]
@="Open command prompt here"

[HKEY_CLASSES_ROOT\Folder\shell\OpenCmd\command]
@="\"C:\\Windows\\System32\\cmd.exe\" /k pushd \"%V\""

Note how the quotation marks and backslashes inside the command line are escaped in the .reg file (\" and \\). O&O RegEditor decodes these correctly on import.

Undoing The Change

To remove the entry, delete the HKEY_CLASSES_ROOT\Folder\shell\OpenCmd key (which also removes its command subkey), or re-import the branch you exported before you started.