Open Command Prompt Here

1 March 2002 by Snakefoot | Comment » | Trackback Off
One can extend the context menu when right-clicking a folder in Windows Explorer, with the option to open a command prompt in that directory. Instead of just opening the command prompt and manually changing to the wanted directory.

Windows Vista will display the option "Open Command Window Here" when right-clicking a folder, while holding down the SHIFT key (Part of the extended context menu options).

Windows XP users can just download the WinXP Powertoy - Open Command Window Here. Previous versions of Windows can use WinXP Powertoy BETA2 - Open Command Window Here, which isn't locked to only work on Windows XP.

To manually add the option through Windows Explorer interface:
  1. Start "My Computer"
  2. In the "My Computer" menu select "Tools" -> "Folder Options..."
  3. Select the fan "File Types"
  4. Sort the registered file types by name by clicking the 2nd column
  5. Find and select the file type "Folder"
  6. Press the "Advanced" button, and a new window pops up
  7. Press the "New..." button, and a new window pops up
  8. Set the action to be :

    Open Command Prompt Here

  9. Set the application to be :

    cmd.exe /k "cd %L"

    Note that the "%L" is used to show the long name of the directory. If you use "%1" then it will use the 8.3 format.
  10. Press Ok to save the newly added entry
Note one can also extend the context menu by applying the following registry settings. More Info MS KB Q320148:

REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="Open Command Window Here"

[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

[HKEY_CLASSES_ROOT\Drive\shell\cmd]
@="Open Command Window Here"

[HKEY_CLASSES_ROOT\Drive\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

Note if not running as administrator by default, and want to open a command prompt session with administrator rights, then it can be done by adding a RunAs option for the directory filetype (Useful if using Windows Vista):

REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open Command Window Here (Administrator)"

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /k \"cd %L\""

[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="Open Command Window Here (Administrator)"

[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /k \"cd %L\""

Related Configure file types to include your own useful actions

Updated: 23 September 2007

Leave a comment


You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>