When I [Shift + Right-Click] a folder that isn't on my C drive and select "Open console here" I get a cmd window up that isn't opened at the correct location, but instead is pointing at C:\Windows\system32. I have to manually switch to the correct drive, but when I do it is then at the correct folder. This is hardly the end of the world, but it's a minor annoyance that's really starting to get on my nerves...

Note: It does work correctly for locations on the Cdrive.

Is this the expected behaviour when used outside of C?

If not, how do I fix it?
If it is, how can I change it to load folders of other drives directly?

For example, if I attempt to open a console window pointing at a folder on my desktop, like so:

Selecting "Open console here" from shift+right click menu for folder on desktop

I get a cmd window pointing at C:\Windows\system32 that I have to manually switch to the D:, but upon doing so you can see that the folder within D: has been selected successfully:

CMD window that initially shows C:\win\sys32 folder, but a single "D:" command changes to correct location.


It seems "Open console here" might be non-standard (see comments).

For completeness, it turns out that I see the probably standard "Open command window here" lower down the list when clicking inside a folder (it's "file space", not on the folder icon itself), as per the image below, so there's some difference between the two that's cropped up:

shift+RMB menu when opened directly from desktop (with nothing highlighted)

  • I can't reproduce this on Win 7 Pro 64-bit. The menu reads "Open command window here" and it does. I tried both a mapped network drive and an actual physical drive. – RBerteig Feb 28 '11 at 22:59
  • I also can't replicate this on Win 7 Ultimate 64-bit SP1. Like @Rberteig, it works fine for me. I almost wonder if you have a shell extension or something that's conflicting? – Shinrai Feb 28 '11 at 23:16
  • Hmmm, I'm at work now, but if I shift-rmb inside a folder (ie, not on a folder icon itself, but within it's "file space") or directly on the desktop there is a seperate "Open command window here" option available much lower down the list (which I'd not spotted before...) and that works. @Shinrai - do you have the same option as me in the same place? If not, I've also thinking some extension is a play. (Suppose I should add this is Win 7 Pro x64 as well.) – DMA57361 Mar 1 '11 at 8:12
  • @Rberteig - please see my previous comment (split as only 1 @ reply per comment). Specifically -- do you have the same option as me in the same place? If not, I've also thinking some extension is a play. – DMA57361 Mar 1 '11 at 8:13
  • @DMA57361, I'll double check at the office, but I don't believe I do. I don't have very many (or any?) extensions installed, so that sounds like a plausible source of the difference. – RBerteig Mar 1 '11 at 9:35

Having examined the registry and asked people on chat, I've determined that the parameters being passed to the instance of cmd that was invoked here were incorrect.

The command can be found in [HKEY_CLASSES_ROOT\Directory\shell\cmd\command] and I had a (Default) value of:

cmd.exe /k cd \"%L\"

Changing this to the following value (obtained in that brief chat session) has resolved the issue:

cmd.exe /s /k pushd \"%V\"

That said, while the problem is fixed, I don't know what caused this change initially...

  • I'll accept this answer (unless someone manages to post something more useful) once the two-day self-accept restriction expires. – DMA57361 Mar 1 '11 at 19:51
  • No need for PUSHD. Use the /D option to CD. – JdeBP Mar 1 '11 at 22:16
  • @JdeBP indeed, that does seem to work. But, since I just obtained the above by getting someone else to look at their Win7 this doesn't come with any reasoning. Do you happen to have a reason why your suggested method would be better than the one I've already ended up with experimentally? – DMA57361 Mar 1 '11 at 22:22
  • I can confirm that my Win7 pro 64 uses pushd as above. I don't know why they use pushd instead of cd /d. – RBerteig Mar 2 '11 at 22:00
  • PUSHD does additional work above what CD /D does. Only if you want that additional work done is it appropriate. It, of course, pushes the prior current directory onto the directory stack. But it also, presuming that CMD extensions are enabled, goes around creating temporary drive letters in certain circumstances. – JdeBP Mar 3 '11 at 3:19

The self-answer by DMA57361 clearly has solved the original problem. I thought I'd add some info I discovered....

First, I noticed a suspicious value in the key HKEY_CLASSES_ROOT\Directory\shell\cmd named Extended. On a hunch, I renamed that value to xxx-Extended and now the "Open command window here" menu item often appears without the Shift key. Since the old tweak-ui solution didn't require the shift key, this discovery makes me happy!

Second, my relatively unmodified Windows 7 Pro 64-bit installation has the registry key HKEY_CLASSES_ROOT\Directory\shell\cmd\command with only a default value of cmd.exe /s /k pushd "%V" set (Note that the type is REG_SZ, not REG_EXPAND_SZ. The meaning of %V (and the reported usage of %L) are not the result of environment variable substitution, and the expansion must be done by Explorer itself.)

The available context menu plugins are listed as subkeys of the registry key HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers. (The other keys in ....\shellex are handlers for other kinds of shell extensions.) One of those handlers, or perhaps one of the other extensions, is probably the origin of the strange default value of the ....\command key.

Edit A neighboring key, HKEY_CLASSES_ROOT\Directory\Background\shell\cmd, also has a value named Extended. It turns out the this one controls the context menu in the folder's content view (right pane, and the desktop itself) while the one named above controls the context menu of folder objects themselves (their icons on the right or on the desktop, or anywhere on the folder tree on the left).

  • Some useful information, especially about disabling the Extended option, so have a +1. Thanks for the input! – DMA57361 Mar 3 '11 at 8:10

pushd is required if you want Windows 7 to switch drive letters to the directory i.e. switch drive also.

The registry key needed looks like the following (I call it DOS) - put it into a .reg file and execute:

Windows Registry Editor Version 5.00


@="\"C:\\WINDOWS\\SYSTEM32\\CMD.EXE\" /s /K  pushd \"%v\""

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.