Search code examples
windowsshellregistrycontextmenu

Windows shell add item to context menu when click on blank part of folder


Sorry if this has been asked before, I've been looking around and it's hard to find what I want.

I know how to add a context menu item to a folder like so:

[HKEY_CLASSES_ROOT\Folder\shell\console2]
@="Open Console2 Here"

[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
@="C:\\Program Files\\Console\\console.exe -d \"\"%1\"\""

but, that only works for right clicking on a folder. I want it so that you can be inside the folder, and click a blank part of that folder and get the context menu item as well. I also tried HKEY_CLASSES_ROOT\Directory\shell as well, but it does the same.


Solution

  • I figured out the answer. The folder is actually Directory\Background, you have to add the empty string value of NoWorkingDirectory into it, and the %1 in the command becomes a %V

    [HKEY_CLASSES_ROOT\Directory\Background\shell\console2]
    @="Open Console2 Here"
    "NoWorkingDirectory"=""
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\console2\command]
    @="C:\\Program Files\\Console\\console.exe -d \"\"%V\"\""
    

    Source: saviert's comment at http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista#comment-57856