IMPORTANT: This article contains information about modifying the registry. Before you
modify the registry, make sure to back it up and make sure that you understand how to restore
the registry if a problem occurs. For information about how to back up, restore, and edit the
registry, click the following article number to view the article in the Microsoft Knowledge Base:
256986 Description of the Microsoft Windows Registry
IN THIS TASK
SUMMARY
This step-by-step article describes how to open a command prompt in a folder on a computer that is running any of the following operating systems:
- Microsoft Windows Server 2003
- Microsoft Windows XP
- Microsoft Windows 2000
If you use a command prompt frequently, it may be helpful to start a command prompt in a specific folder instead of using the
cd command to move to the folder that you want. You can place a
Command Prompt command on the shortcut menu in My Computer or Windows Explorer to start a command prompt in the folder that you want.
You must modify the registry to add the
Command Prompt command. You can modify the registry manually, or you can use a script.
back to the top
To Add a "Command Prompt" Command
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may
require you to reinstall your operating system. Microsoft cannot guarantee that you can solve
problems that result from using Registry Editor incorrectly. Use Registry Editor at your own
risk.
back to the top
Modify the Registry Manually
To add the
Command Prompt command to the shortcut menu:
- Click Start, click Run, type regedit, and then click OK.
- Locate the following registry key:
HKEY_CLASES_ROOT\Directory\shell
- Right-click the shell key, point to New, and then click Key.
- Name the new key OpenNew.
- Click the OpenNew key, and then double-click the Default value in the right pane.
- Change the value to Command Prompt. Click OK.
- Right-click the OpenNew key, point to New, and then click Key.
- Name the new key Command.
- Double-click the Default item in the right pane.
- Change the value to cmd.exe /k cd %1.
If you have multiple drives on your computer, you can add a similar command to the shortcut menu that appears when you right-click a drive in Windows Explorer or My Computer. The steps to do this are the same as those for creating the
Command Prompt command, except that you use the
HKEY_CLASSES_ROOT\Drive\shell registry key as the starting point. Also, change the value of the
Default value in the
HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command key to
cmd.exe /k.
back to the top
Modify the Registry with a Script
To add the
Command Prompt command to the shortcut menu:
- Copy the following text to a file named Cmdhere.reg:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew]
@="Command Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew\Command]
@="cmd.exe /k cd %1"
- Save the Cmdhere.reg file.
- Double-click the Cmdhere.reg file to automatically add the registry entries.
back to the top