'Command Prompt Here' on Explorer Context Menu

AID: 1052
  • Status: Published

5040 points

  • By
  • TypeTips/Tricks
  • Posted on2009-06-26 at 23:37:32
Awards
  • Community Pick

Programmers and system administrators often find it necessary to get to a command prompt (a "DOS box") in a certain directory.  This article describes how to set up a context menu for Windows Explorer to do that.   When finished with these simple steps, you will be able to right-click any folder name in the Explorer, select Command Prompt here... and begin entering commands in a DOS box with the selected directory having been set as desired.

ArticleCmdPromptHere-1.JPG
  • 53 KB
  • Context Menu for Explorer
Context Menu for Explorer
ArticleCmdPromptHere2.JPG
  • 15 KB
  • Gets to DOS prompt easily
Gets to DOS prompt easily


1
In any Windows Explorer, select Tools / Folder Options... and click the File Types tab.

ArticleCmdPromptHere3.JPG
  • 20 KB
  • Folder Options
Folder Options


2
Scroll down to find the Folder entry -- the Extension is "(None)"  Click it and then click the [Advanced] button.


3
In the Edit File Type dialog, click [New...]


4
In the New Action dialog, click fill in the values:
       Action: Command Prompt here...
Application: Cmd.Exe

ArticleCmdPromptHere4.JPG
  • 11 KB
  • New Action
New Action



5
OK the the New Action input, OK the Edit File Types box, and OK the Folder Options dialog.  You are done.



The Context Menu change will take effect immediately.  Use the Windows Explorer to drill-down to any depth of folder on any disk.  Right-click the folder and select Command Prompt here.

Some notes:  
  • If you select a virtual folder, the "current directory" may well be one that you have never seen "naked" before.  For instance, the "My Documents" folder ends up in the correct user's "Documents and Settings" folder.

  • If you later try to remove the new Context Menu item, you may find that the "Remove" button is not enabled.  You may need to go to the registry to make changes.  You could use RegEdit to modify the EditFlags of the Folder settings in
        HKEY_CLASSES_ROOT\Folder
    But I'd not recommend that.   Instead, just locate the subkey that we created...
       HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here
    and remove it entirely.

  • If you don't want to do all of those manual steps, you can add the Context Menu item using a registry file.  Just copy the following snippet to a text file named, for instance, CmdHere.reg then double click it.

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here]
    @="Command Prompt Here"
    
    [HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here\command]
    @="Cmd.Exe \"%1\""
                                      
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    

    Select allOpen in new window



  • I recently learned that Windows Vista has a built-in (though not well known) ability to do exactly what this article describes.  With Vista, if you press the SHIFT key while right-clicking a folder, then an "Open Command Window Here" item is added to the context menu.  Thanks to evilrix for that tip!


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you liked this article and want to see more from this author,  please click the Yes button near the:
      Was this article helpful?
label that is just below and to the right of this text.   Thanks!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  

OldFashonedDan2.JPG
  • 7 KB
  • Dan Rollins
Dan Rollins
    Asked On
    2009-06-26 at 23:37:32ID1052
    Tags

    Command prompt

    ,

    DOS box

    ,

    Explorer

    ,

    Cmd

    ,

    context menu

    ,

    batch file

    Topic

    DOS and Windows

    Views
    3733

    Comments

    Expert Comment

    by: GFCU on 2009-07-01 at 12:42:17ID: 1879

    If you make the mistake of adding an action or setting that you don't want, for instance the folders all open in new windows... How do you delete the action... I've noticed that there are Edit and Remove buttons on the window, but they are greyed out...

    Author Comment

    by: DanRollins on 2009-07-01 at 15:02:20ID: 1880

    The options that are greyed out relate to the "Edit Flags"  in the registry.  It is possible to use RegEdit to change the flags to enable Edit and Remove, but as I stated in the Article, your best bet is to just use RegEdit to delete the new entry.  Warning:  Be careful using RegEdit -- especially with with important "file types" as "Folder"

    Expert Comment

    by: GFCU on 2009-07-02 at 06:09:55ID: 1888

    wow... Maybe I should read through the entire article before asking a question that was already answered ehh? :-(

    Oops...  Thanks for your patience and help with this matter... it seems weird however that the setting for those buttons to work must be changed in the registry... yet at the same time I can see why, because you don't just want a user to accidentally edit or remove something and not know how/what it contained in the first place.

    Thanks again... hopefully we'll be all set now.

    Expert Comment

    by: johnb6767 on 2009-07-02 at 07:02:52ID: 1898

    I would suggest including this here, for the non technical persons. Where they can install/uninstall the tweak as needed...

    Open Command Window Here
    http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe

    Microsoft has a quick installer that does this for you already....

    Just wanted to add it........

    Expert Comment

    by: TedInAK on 2009-10-20 at 01:54:05ID: 4483

    Been using the aforementioned PowerToy for years...another indispensible tool is "Open Target Folder" option for shortcuts.  

    http://www.winwonk.com/utils/OpenTarget/

    After installing, simply right-click a shortcut, click "Open Target Folder" and viola!  No more right-click, choose properties, then click on "Find Target".

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Loading Advertisement...

    Top DOS & Windows Experts

    1. DanRollins

      280

      0 points yesterday

      Profile
      Rank: Genius
    2. nordtorp

      80

      0 points yesterday

      Profile
      Rank: Guru
    3. adiloadilo

      70

      10 points yesterday

      Profile
      Rank: Master
    4. v_prawin

      30

      10 points yesterday

      Profile

    Hall Of Fame