How to Add a Context Menu in Windows 7 Library Folders

7

5

I just finished setting up my Dev environment on a Windows 7 PC. For command line and Terminal use, I installed the program called Console2 which is amazing for anyone who uses the Terminal on a Windows machine.

One of the important things I needed was the ability to access folders in the terminal quickly without always doing cd /directroy/name/etc/etc so my goal was a Right Click Context Menu inside of a folder in Explorer.

I was able to get this done with the following Registry Key modifications/additions

[HKEY_CLASSES_ROOT\Directory\shell\open_console]
@=Open Console2 Here
Icon=C:\Program Files\Console2\Console.ico

[HKEY_CLASSES_ROOT\Directory\shell\open_console\Command]
@=C:\Program Files\Console2\Console.exe -d "%v"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\open_console]
@=Open Console2 Here
Icon=C:\Program Files\Console2\Console.ico

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\open_console\Command]
@=C:\Program Files\Console2\Console.exe -d "%v"

It works great, I can now see a context menu to open a terminal window at a folder's path in 2 way.

  1. By right clikcing on a folder name, it will show the "Open Console2 Here"
  2. By opening a folder and right clikcing in the background, I can see the same context menu to open terminal as well.

Now my problem is I often access folders and work areas using Windows Libraries, this make my context menu not work when I am accessing a folder through the Library instead of going directly to the folder.

For example if I open Explorer and go to...

E:\Server\htdocs\labs\javascript\SampleJSProject then I can view and use my custom context menu.

However if I access that same folder using my shortcut/libraries, the path then looks like this...

Libaries\Server Labs\javascript\SampleJSProject and now my context menu to open terminal does not show up. If I click in the Address area it then shows the correct full path as listed above though.

I am hoping it is an easy solution, like adding another registry key somewhere but I am not sure where?

Does anyone have any ideas or solutions?

JasonDavis

Posted 2013-01-12T22:54:59.157

Reputation: 4 852

You could right click > Open folder location before opening console. Kind of a temp solution, but it works. – Sam – 2013-01-21T08:34:51.147

Answers

9

The trick here is that Library Folders have their own key.

Oddly enough its "LibraryFolders" so you would need to modify THAT key to get the effect you want.

For example, to add the "Open command window here" context entry to a Library Folder, use the following reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\LibraryFolder\Background]

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell]

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\cmd]
@="@shell32.dll,-8506"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\cmd\command]
@="cmd.exe /s /k pushd \"%V\""

HTH

-(e)

sweetlilmre

Posted 2013-01-12T22:54:59.157

Reputation: 190

1Amazing... all along the reason it wasn't working was due to explorer treating library folders differently. Thanks for this! – Taliesin – 2014-07-24T07:01:59.043

@jasondavis please mark the answer as correct if it worked for you. – sweetlilmre – 2015-04-19T17:27:34.613

3I have been looking for this functionality for a long time, thanks for sharing! – JasonDavis – 2013-04-16T13:26:20.570

0

To expand on sweetlilmre's answer:

If you don't have the rights to edit HKEY_CLASSES_ROOT (a problem that arose for me on my company laptop), you can also edit HKEY_CURRENT_USER\Software\Classes\LibraryFolder\Background\shell\cmd\command.
You may have to create LibraryFolder and its sub-keys (I had to), but it's enough to create empty keys.
cmd can also be named differently, the only thing that matters is the value of that key (which is the text shown in the context menu) and the command key, whose value will be executed. It's apparently sufficient to use cmd.exe as the command; the command line automatically launches in the directory you right-clicked in, no additional parameters necessary (at least on Win 7 Enterprise, which I'm using).

I'm not particularly familiar with registry-editing scripts, so I did this stuff manually. If anyone knows how to phrase the information above in a script, feel free to edit it into this answer.

Bonus: if you add a string key to cmd (or whatever you named it) called "Icon" and set to "cmd.exe", your context menu entry will also be accompanied by an icon.

See these images on how your registry should look like after the above steps (as mentioned, LibraryFolder is a child of HKEY_CURRENT_USER\Software\Classes):

enter image description here

enter image description here

PixelMaster

Posted 2013-01-12T22:54:59.157

Reputation: 101