How to Change Default Windows Command Prompt Directory

When opened, the Command Prompt in Windows usually points to your profile, i.e., Documents and Settings/username.

Most of the time, this isn't a useful starting point and the user has to navigate away to another directory.

If you tend to use a certain directory a lot from the Command Prompt, then it makes sense to make it the default directory when the Command Prompt opens.

To do this, you'll need to edit the Windows registry:

1) Click the Windows key on your keyboard and the R key simultaneously (Win+R) or if you don't have a Windows key, hit CTRL+ESC (works for XP, from which I am writing; don't know about Vista) and the select Run.

2) In the run box, type regedit.

3) Once in the registry, make sure to back it up by going to File > Export and then select a location to store the backup and name it. Then hit Save.

4) Now navigate to
HKEY_CURRENT_USER\Software\Microsoft\Command Processor and look for the String called "Autorun" in the left window. If that string does not exist then create it by right-clicking in the right pane and selecting New > String Value. After locating or creating the Autorun string, double-click it and add the new directory path in the following way:

CD /d c:\MyPreferredDirectory

The change takes place immediately.

Now, let's explain what we did. The "CD /d" portion of the string, according to the help function (bring up help for CD by typing "CD /?") for the CD command "changes the current drive in addition to changing the current directory." Thus the default directory for the Command Prompt changes before it is displayed to the new directory you specified.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.