Monthly Archives: May 2009

“Command Prompt” in Windows Explorer Context Menu

There’s a great power-toy for adding “Command Prompt” to the Windows Explorer context menu in XP here (or search for XP Power Toys). In Vista and Server 2008, you just hold shift when you right click to get it — built in. But what if you’re on Windows Server 2003 or another version? Well, the technique to add it is just a simple registry change:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellCommand_Prompt]

@=”Command Prompt”



[HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellCommand_Promptcommand]

@=”cmd.exe /k pushd “%1″”

Copy the above into a reg file (such as “Command Prompt Here.reg” — no quotes) or similar, double-click to merge it, and you’ve got a Command Prompt selection in Windows Explorer’s context menu. Easy as pie. If you want to “uninstall” it, open up RegEdit, navigate to that key, and delete it. Changes take effect immediately.

Note: some have reported this syntax brings up an error. If cmd.exe isn’t in the PATH, this will utterly fail. In some cases I’ve had success with changing the command to be @=”cmd.exe “%1″”. In some cases, that utterly fails too. Your mileage may vary, batteries not included, don’t use this product while sleeping on a curling iron or driving in traffic.

And to take it a step further, I modified the command name to “Command Prompt x86” and the command to “C:WindowsSysWoW64cmd.exe “%1″” and imported into a new key name, and I now have a 32-bit command prompt in the pop-up too.

(Now hopefully I won’t forget it again.)

EDIT:
This is a great technique for getting these commands on the right-click menu for the explorer tree, but what if you also / instead want them for blank space on the folder details?  A bit of experimentation, and it seems the path for these is HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryBackgroundshellCommand_Prompt.  (Note how Folder became DirectoryBackground.  The full file becomes:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryBackgroundshellCommand_Prompt]

@=”Command Prompt”



[HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryBackgroundshellCommand_Promptcommand]

@=”cmd.exe /s /k pushd “%V””

Why is the parameters to cmd different?  Not sure.  But it seems to work.  :D  And now I can fling these shortcuts both to the tree and to the folder details.  Nice.