Why doesn't "Open console here" open cmd on the correct drive if not used on the C-Drive?
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 C
drive.
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:
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:
Update
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:
Solution 1:
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...
Solution 2:
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).
Solution 3:
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
[HKEY_CLASSES_ROOT\Folder\shell\DOS]
[HKEY_CLASSES_ROOT\Folder\shell\DOS\command]
@="\"C:\\WINDOWS\\SYSTEM32\\CMD.EXE\" /s /K pushd \"%v\""