Windows – cmd.exe customizing the “Open Command Prompt here” shell extension

command linewindowswindows 7windows-registry

Thought I would see if anyone had any pointers on the following situation. I've been customizing command prompt to my needs, and recently changed the prompt for my user. Instead of displaying the path in the prompt, I would like it to always be the window title.

I put a new registry key at

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Command Processor/AutoRun

with value

title %cd% 

This script runs any time command prompt starts.
This works. Whenever I open a command prompt via shortcut, this acts properly.

However, whenever I open a command prompt via right click -> Open Command Prompt Here this apparently doesn't execute. I tried looking at the shell command for open here located at

HKEY_CLASSES_ROOT/Directory/shell/cmd/command

which by default is set to:

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

I tried changing this to:

cmd.exe /s /k "cd %1 & title %cd%"

The "%1" was suggested at other places online for an open-here script, and If I understand correctly the & should execute both commands. However, it still does not work every time I open command prompt here. The working directory is indeed correct, the the window title is still "C:\Windows\System32"

Any pointers?

Best Answer

You were pretty close to solution. For me the following command works:

cmd.exe /s /k "pushd ""%V"" & title %V"

EDIT: There are several places in registry supporting the "Command Prompt Here" shell extension. For this change to work consistently across all objects (directories, drives and special folders), you have to search the registry for all occurrences of cmd.exe /s /k pushd "%V" and replace them with the value above.