How to change the default startup directory for Command Prompt?

Published: Jun 2004
Updated : Dec 2007
Send your feedback


When you open a Command Prompt window (CMD.EXE), it defaults to your user profile home directory. If you wish to change the default startup directory for Command Prompt, use the steps listed in this article.

CAUTION Changing the current directory using Autorun value as mentioned in this article, might affect the functionality of batch scripts. For more information, read the post Hidden gotcha: The command processor's AutoRun setting at Raymond Chen's blog. Also, changing the startup directory using Autorun affects the functionality of the CmdHere Powertoy as well. Read below... If you decide to modify the default startup directory by editing the Autorun value, you do so at your own risk.

Set the default startup directory

HKEY_CURRENT_USER \ Software \ Microsoft \ Command Processor

Example:  To set the startup directory to F:\Windows, set the Autorun value data to CD /d F:\Windows

You may also use a batch file so that it executes the contents automatically upon launching the Command Prompt. To view the entire list of arguments supported by CMD.EXE and their description, type CMD /? at the Command Prompt.

More information

You can also set the default Prompt in the Autorun key. To execute more than one command automatically at Command Prompt startup, type the commands in a Notepad document and save as a .BAT file. Then, type the full path to the batch file in the Autorun field in the registry. Sample Batch file:

@echo -------------------------
@echo Welcome to Command Prompt
@echo -------------------------

Minor side-effect - "Autorun" value and CmdHere Powertoy

Open Command Window Here PowerToy adds an Open Command Window Here context menu option on file system folders, giving you a quick way to open a command window (cmd.exe) pointing at the selected folder. The Open Command Window Here functionality is affected if you set the Command Processor Autorun value as described earlier in this article.

To re-enable the functionality of Open Command Window Here PowerToy, and have the Command Processor Autorun feature enabled at the same time, use these steps:

HKEY_CLASSES_ROOT \ Directory \ shell \ cmd \ command

cmd.exe /k "cd %L"


cmd.exe /d /k "cd %L"

Note: If /D parameter IS specified on the command line, then when CMD.EXE starts, it ignores the AutoRun registry variables in the following locations.

HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Command Processor \ AutoRun

HKEY_CURRENT_USER \ Software \ Microsoft \ Command Processor \ AutoRun

Related article

"The command prompt has been disabled by your administrator" message