ghacks Technology News

Change the default Command Prompt directory

Whenever you open the Command Prompt in Windows you are taken to a default directory which is usually your Documents and Settings \ Username directory. Most of the time you navigate away from it because you need to access files that cannot be accessed from there.

I decided to go a step further and change the default Command Prompt directory to c:\windows\system32. That is my choice, you can set it to any directory that you want. To change the default Command Prompt directory open the Registry by pressing Windows R, typing regedit and hitting enter.

Navigate to the key HKEY_CURRENT_USER \ Software \ Microsoft \ Command Processor and search for the String Autorun in the left window. If that string is not existing yet create it. Double-click it afterwards and add the new directory path in the following way:

CD /d c:\windows\system32

Changes take effect immediately which means you can test right away. The default directory for the Command Prompt is changed before it is displayed which means that you already start in the new folder that you have selected.

Enjoyed the article?: Then sign-up for our free newsletter or RSS feed to kick off your day with the latest technology news and tips, or share the article with your friends and contacts on Facebook or Twitter.

Related Articles:

Command Line Directory Switcher
Save Your Skin by Customizing Your Bash Prompt
Enable Quick Edit Mode To Copy Command Prompt Items More Efficiently
Change the Print Spooler Directory
Change Default Browser, Quickly Switch The Default System Browser



About the Author:Martin Brinkmann is a journalist from Germany who founded Ghacks Technology News Back in 2005. He is passionate about all things tech and knows the Internet and computers like the back of his hand. You can follow Martin on Facebook or Twitter.

Author: , Friday November 16, 2007 -
Tags:,


Responses so far:

  1. Obi-Wahn says:

    Well I’m not sure if this hack was on ghacks allready, but to get a Shell-Context-Menu entry to open the command prompt in a choosen folder, just save this:

    ;start here
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\cmd]
    @=”Open Command &Promt here…”

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

    [HKEY_CLASSES_ROOT\Drive\shell\cmd]
    @=”Open Command &Promt here…”

    [HKEY_CLASSES_ROOT\Drive\shell\cmd\command]
    @=”cmd.exe /k \”cd %L\”
    ; end here

    into a file (commandprompt.reg) and add it to your registry.

  2. Martin says:

    No it has not yet Obi, thanks for mentioning it.

  3. Vivek says:

    Nice hack! That’s really clever :)

  4. anubhav says:

    no this does not work

  5. Manju says:

    Hey anubhav, that does work.
    Thanks Martin.

  6. Tim says:

    anubhav, it does work. You’ve got to create the key if it isnt there, create it as a string then edit it to the path.

  7. pk says:

    xp wont let me add to reg.
    can not import, not a reg script, only import binary reg. files.

  8. del says:

    then do it manually

  9. Daniel says:

    sorry im pretty newb. whats this thing that obi posted do? if its complicated then either dont worry or link me to something. thx.

  10. Hank says:

    I actually had a different starting directory and wanted to get back to c:\

    This regedit definitely worked for me.

    Does anyone know how to do it from the command prompt w/o regedit though?

  11. Rarst says:

    >Does anyone know how to do it from the command prompt w/o regedit though?

    Well, cmd help points to those registry settings… If you really want to play around it you can just make .bat (.cmd) file that runs console and goes to directory needed. Something like this:

    cmd /k cd “c:\”

  12. Kent says:

    Hi Rarst
    You can open command prompt from a drive by shift right clicking the drive and clicking on the open command prompt here on the popup menu
    Kent

  13. Saravana says:

    Hi,
    thank you so much

  14. Rj says:

    I dont c autorun???

  15. Rj says:

    Ummmm i dont c autorun…can anybody help me, im so nooob at this kinda stuff.>=|

  16. magicyte says:

    @ Rj

    When here in the registry editor …

    HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor

    … right-click in the white space, if there is no variable named “Autorun” and click “New” in the menu which was opened after the right-click. Name the variable “Autorun”. Select “String” from the choices of the type of variable and click OK (or whatever button there is that signals to add the variable). You should then see a variable called “Autorun” in the margin. Double-click on it and in the “Value:” textbox, put …

    CD /d X:Y

    … where X is your current drive and Y is the folder you want the default prompt to be. If you do not understand this, just ask and it shall be given unto.

    - magicyte

  17. Hima says:

    thats so easy to tweak!

  18. a says:

    Nice thing.Thanks……….

  19. TR says:

    Nice one thanks

  20. Ajay says:

    Thank you, it worked perfectly on my Windows 7 as well:)

  21. sa says:

    thanks alot dear it works..

Leave a Reply   Follow Ghacks   Subscribe To Comment Rss

Subscribe without commenting

© 2005-2012 Ghacks.net. All Rights Reserved. Privacy Policy - About Us