Command prompt shortcut

Frequently while developing I need to use the command prompt.
Compiling, batch files, copying files, build scripts, etc. and its
always a pain to open the command prompt and then navigate to the
directory that you want to work in.  To make my life a little
easier, I tweaked the registry a little, and added a command prompt
item to the folder context menu, so when I select the “Command Prompt”
item, it opens cmd.exe and moves into the current folder.


DISCLAIMER: Be very careful when modifying your registry and always
make a backup before changing anything. I give no warranties :)

Here is what you add to the registry in order to get this:
1. Go to HKCR\Directory\shell
2. Right click on ’shell’ and select ‘New Key’
3. Change the name of the new key to “Command Prompt”
4. Right click on the new key and select ‘New Key’
5. Change the name of this new key to “command”.
6. Select this new key and right click on its default value:

7. Select “Modify” and in the input box enter this text: cmd.exe /k “cd %1%” (include the quotes)
8. Thats it! You should be able to right click on your folders and get a command prompt.

13 Comments

  1. Anonymous said,

    Wrote on May 11, 2005 @ 7:46 pm

    Cool… i always knew it was possible but it’s nice to have step-by-steps to save me having to think about it! I’ve always copied and pasted the address bar content into a command prompt to do the same thing… quite sad really :)

  2. Anonymous said,

    Wrote on May 11, 2005 @ 8:14 pm

    If you’re feeling a little lazier there’s also an XP PowerToy called “Command Prompt Here” that does the same thing I think.

  3. breichelt said,

    Wrote on May 11, 2005 @ 8:32 pm

    John, I always did that too, thats what I got sick of doing, its the little things, ya know :)

  4. Anonymous said,

    Wrote on May 11, 2005 @ 9:33 pm

    One thing I did think to automate was the reverse — getting from the prompt to an explorer window with folders showing.

    explorer .,/e

    Of course you probably knew that already but I thought I’d mention it anyway coz I use it all the time!

  5. breichelt said,

    Wrote on May 11, 2005 @ 9:47 pm

    Actually, I hadn’t thought of that one, but I’ll keep it in mind

  6. johnpapa said,

    Wrote on May 11, 2005 @ 9:58 pm

    Ben & John … Very cool stuff. Both are very simple and convenient. Never really thought about “how”, now I don’t have to. Thanks!

  7. Anonymous said,

    Wrote on May 12, 2005 @ 12:37 am

    The ‘Open Command Window Here’-powertoy has been available since Windows 95 PowerToys.
    Since this has been available since Windows 95 I am quite amazed that MS has not added it by default to Windows!

    Here is the link to get it: http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

    You should also check out ClearType Tuner and Tweak UI!

  8. Anonymous said,

    Wrote on May 12, 2005 @ 5:30 am

    You should really instll the interesting bits of both windows 95 power toys AND XP power toys.

    I use “command here”, “file name to clipboard” and “send to any folder” almost every day.

    I did remove alot of the default win95 email “send to” items

    And it should be LAW to have note pad (well notepad2 really) in your send to.

    Finaly I have found that renaming the send to items with a numeric prefix allows for a neater menu.
    1. Notepad
    2. Clipboard as Name
    3. Any Folder…
    4. Run Command
    5. Clipboard as Contents

  9. Anonymous said,

    Wrote on May 12, 2005 @ 6:08 am

    I created a .reg file with these settings to make it a no-brainer to install. I can’t post an attachment here, but you can save the following to a .reg file, double-click it, and you’re done:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\Command Prompt\command]
    @=”cmd.exe /k \”cd %1%\”"

    -Michael

  10. rlewallen said,

    Wrote on May 12, 2005 @ 6:21 am

    Awesome. I exported that key entry and now don’t have to remember where it goes, I can just merge the .reg file.

  11. breichelt said,

    Wrote on May 12, 2005 @ 6:52 am

    I’m definitely going to look into the power tools, it seems like they have a lot of great little time savers, thanks for all the suggestions!

    I was going to create a .reg file and make it available for download from the post, but I couldn’t get my ftp working, so I had to go without it :)

  12. Anonymous said,

    Wrote on January 20, 2006 @ 10:51 am

    One issue I found was directory paths with longer than 8 letters show up with the ~1, in place of the extra letters (as in C:\DOCUME~1\ADMINI~1\Cookies). This was an old windows problem (when folders could only be 8 characters long). If you manually navigate to the path today, you get the full path name…

  13. Anonymous said,

    Wrote on January 20, 2006 @ 11:32 am

    Try:
    cmd.exe /k “cd %L”

Comment RSS