One of the things that irks me is I’m trying to do stuff in a deeply buried directory in Explorer and the realize that I want to do something Command Prompt related. You get all the way down to where you want to be and say “uwaaaah!” because you realize that you now have to type that long path into a command window. Sure you could copy the path from the directory bar and paste in the command window, but, well, that’s a bunch of steps I don’t feel like dealing with.
In Vista, there’s an addition challenge because you might want a Command Prompt with Elevated permissions.
Below you’ll find a set of Registry settings that will enable a “Command Prompt here” and “Elevated Command Prompt here” menu item when you right click on a drive or directory in Explorer, including the
Start Menu Vista Button.
First, the obligatory “if you screw up your computer by using this Registry setting, you can’t blame me”. Having said that I’ve got it running on four machines without any ill side effects, so I’m content to say that this is “good to go”.
Second, the obligatory history. Command Prompt here is the name of Power Toy for Windows XP. Works fine for XP, but not so much on 2003 or Vista. In fact, it will work – the Power Toy simply adds some keys to the registry – but the installer gets cranky. Since I use Windows XP, Windows 2003, and Windows Vista, I wanted something that would work on all three.
For what it’s worth, Vista already has Command Prompt here in the menu but it’s normally hidden. It comes down to a single REG_SZ value called Extended, which is removed as part of the Registry file below. If you don’t want to lose the hidden option, remove these two lines. I want it to always be there, so I delete that REG_SZ value.
However, that doesn’t address the problem of Elevation. I first thought “wouldn’t it be nice if there was sudo command” but I haven’t found one yet. Then I found another registry option: runas. Adding this to the Registry settings adds another item on the Explorer context menu that allows you to open a elevated Command Prompt. If you only want it to show on a Shift + right-click, add a new REG_SZ value named Extended (and with no value set).
Also, because all of these use pushd rather than cd this will work across drives.
How do I get this for my Vista machine! Well, I don’t like the idea of having REG files for people to download: too many people that shouldn’t have access to REG files will and I don’t want to encourage that. It’s bad enough people willing bid on eBay auctions like “ZOMG! PS4!” and then complain that they got two PS2’s taped together – and those people had to not only bid but send money through PayPal… so for this, I’ll give you the contents of the REG file: you copy if from here, paste it into a file named PromptHere.reg, and merge that into your registry. If you don’t know what I just said – and you’re still reading this – ignore this post! And of course, you can always edit the registry by hand.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\cmd] @="Comm&and Prompt here" "NoWorkingDirectory"="" "Extended"=- [HKEY_CLASSES_ROOT\Directory\shell\cmd\command] @="cmd.exe /k \"pushd %L && title Command Prompt\"" [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Ele&vated Comm&and Prompt here" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /k \"pushd %L && title Command Prompt\"" [HKEY_CLASSES_ROOT\Drive\shell\cmd] @="Comm&and Prompt here" "NoWorkingDirectory"="" "Extended"=- [HKEY_CLASSES_ROOT\Drive\shell\cmd\command] @="cmd.exe /k \"pushd %L && title Command Prompt\"" [HKEY_CLASSES_ROOT\Drive\shell\runas] @="Ele&vated Comm&and Prompt here" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Drive\shell\runas\command] @="cmd.exe /k \"pushd %L && title Command Prompt\""
That’s it. You can all thank me later. It will also work on XP or 2003, but the Elevation – the four sections above with \runas\ – are typically and I think both would ignore the “NoWorkingDirectory” values. Or you can just download the Command Prompt Here Power Toy. This whole thing was about Vista.
I know: it’s neat – I love it too!