Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

January 09, 2000 12:00 AM

How can I open a command prompt at my current directory in Explorer?

Windows IT Pro
InstantDoc ID #13571
Rating: (5)

A. It may be a normal situation you are browsing directories in Explorer and want to open a command prompt at the current location without having to type a long cd .... to get to the correct directory. It is possible to add a context menu option to folders to bring up a "Command prompt here" which will open a command prompt at your current explorer location.

A Powertoy, Command Prompt Here, can be downloaded from Microsoft (and is also included with the resource kit, cmdhere.inf), however all this does is update a couple of registry entries and can be accomplished manually allowing greater flexibility

  1. Start the Registry Editor (regedit.exe)
  2. Move to HKEY_CLASSES_ROOT\Folder\shell (you could use HKEY_CLASSES_ROOT\Directory\shell but it would then not apply to folders, whereas Folder does both)
  3. From the Edit menu select New - Key and enter a name of CmdHere (or anything else)
  4. Under the new key select New - Key and enter a name of command (lowercase)
  5. Under the key (CmdHere), double-click (Default) and enter a name that will be displayed when you right click on the directory, e.g. "Command Prompt Here"
    As an extra, if you a & to the front of a character it will cause it to be underlined, e.g. "&John Prompt here" would produce John Prompt here.
  6. Move to the command key and again double-click (Default) and enter
    \System32\cmd.exe /k cd "%1"
    e.g. c:\winnt\System32\cmd.exe /k cd "%1"
    You can use "%l" instead of "%1" which will support long file names.
  7. Close the registry editor

An example registry file might look like:

[HKEY_CLASSES_ROOT\Folder\shell\CmdHere]
@="Command Prompt Here"
 
[HKEY_CLASSES_ROOT\Folder\shell\CmdHere\command]
@="cmd.exe /d cd \"%1%"

There is no need to reboot the machine and the new option will be available when you right click on a folder

Click here to view image

In Windows 2000 applying this change also results in a command prompt here for drives and not just folders


Related Content:

ARTICLE TOOLS

Comments
  • Anne
    4 years ago
    Sep 04, 2008

    LeoZao, here's an answer to your question from John Savill: "It seems that the only way to add an icon is to create an Explorer shell extension. If you are just adding an entry to the “Open With” context menu item for a specific file type we can add a DefaultIcon entry but this won’t work for normal Explorer context menu items we add. Time to start coding if you want an icon!"

  • Anne
    4 years ago
    Aug 26, 2008

    LeoZao, Please see John Savill's answer to =Snappy's question in the page 1 comments. He provides the registry info for adding the icon. If this is not what you're looking for, let me know, and I'll pass along your question to John. Thanks for reading!

  • LeoZao
    4 years ago
    Aug 25, 2008

    This article is very good...it help me to add that item in the folder context menu. But how do i proceed to add my icon in the left side of the command "Command Prompt Here". Is this possible? Thank you!

  • Neer
    6 years ago
    Jun 30, 2006

    Hello,

    I would like to contribute a free, complimentary, utility called BackgroundCMD, which allows you to open a command prompt in any directory, from *within* the directory. I wrote it to be useful in those situations where you realize you need to open a console window only after you've entered the directory. It works by adding an item to the folder *background* context menu.

    Additional details and downloads are available at:
    http://www.roggel.com/NGNeer/BackgroundCMD

    Regards,
    The NGNeer.

  • Anonymous User
    7 years ago
    Feb 26, 2005

    By the way, I forgot to mention just a moment that in case you cant do it like that, you can download the cmdhere.inf installer from: http://www.winscripter.com/Downloads/Downloads_GetFile.aspx?id=39

    Just better if you do it yourselves...

    --Cookie

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.