Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 



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

RSS
Subscribe to Windows IT Pro | See More Registry Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

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


End of Article



Reader Comments
This is really useful and exciting thing thanks a lot...

raj December 08, 2000


This this is about as ambiguous as it can get. I've spent the last 30 minutes trying to get it to work; it doesn't want to. The next time something required registry editing, please include a picture of the structure under regedit, instead of the completely useless picture of how it looks after the command is successfully completed.

Nipun December 09, 2000


john,

it would be _very_ helpful to include a sample .reg file (like the one in the appendix) in the article that does the neccessary changes.

thomas

----8<--- snip --->8---
REGEDIT4

[HKEY_CLASSES_ROOT\Folder\shell\CmdHere]
@="&Command Prompt here"

[HKEY_CLASSES_ROOT\Folder\shell\CmdHere\command]
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%l\""
----8<--- snip --->8---

Thomas Vogler January 06, 2001


I have tried as mentioned in this article.But it is not working it shows message "This file does not have a program associated with it for performing this action"

vinod November 13, 2002


this is a great for non DOS folks. I used is routinely and switched to another server and was lost. luckily I found it again. thanks a lot.

lynn wheeler March 17, 2003


I had the same problem as Vinod. I keep getting a This file does not have a program associated with it for performing this action. It would be helpful if you tested this stuff out. The directions are ambigious at best, and it seems that you have not updated the note even after similar comments from other users. Oh well... thanks for trying.

Rajeev June 02, 2003


You could also perform the above via a GUI front end by selecting View - Folder options - File Types from Explorer.
Application:
CMD.EXE /K CD /D "%1"
That's all!

Johannes van Kessel July 28, 2003


let's up the stakes a little bit: how do you put the icon with it?!

=Snappy= August 21, 2003


Example registry file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\CmdHere]
@="Command Prompt Here"

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

Hope this helps

John

John Savill September 04, 2003


Good stuff. It works

rat_cunning June 03, 2004


 See More Comments  1   2 

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. ...

Microsoft Warns of Windows Version Expirations

Microsoft warned that this year will see three out-of-date Windows versions slip into retirement. ...


Scripting Whitepapers Three Ways to Prevent Insider Risk within Your SCCM-Managed Environment

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Configuration Manager SP1 and R2 Overview

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement