Change Command Prompt Default Directory

Page 1 of 2 12 LastLast

  1. Posts : 759
    Windows 7 Enterprise x64
       #1

    Change Command Prompt Default Directory


    This is a simple registry hack to change the default directory you see when opening command prompt. I like to have it set to the OS root drive, but you can change it to whatever you like. This will keep you from having to use the "change directory" switch every time you open command prompt, which can be more than a little annoying.

    1.) Open up registry editor by typing "regedit" [without the quotes] in the search box, and then clicking on the link up top.

    2.) 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:\

    3.) If you would like the command prompt to open in the system32 folder, use this string instead:
    CD /d C:\windows\system32

    4.) Close the registry editor, and then open the command prompt to check your work.

    As you can see, you can easily change the default directory to whatever you like. Hope this helps you from being annoyed at the command prompt.

    Here's the rusult....




    Max
      My Computer


  2. Posts : 1,170
    XP Pro SP3 X86 / Win7 Pro X86
       #2

    MadMaxData said:
    This is a simple registry hack to change the default directory you see when opening command prompt.
    Hi Max... why would you do that?

    In your start bar find the command prompt shortcut, make a copy of it in a convenient place...

    Right click and select properties... You will see this....

    Change Command Prompt Default Directory-capture.jpg

    In the "Start in" box type the path where you want the command prompt to open.
    You can even make multiple copies of the shortcut and have them available to open in any convenient place you like...

    Change Command Prompt Default Directory-capture2.jpg

    In addition there are a number of variables that can be used...

    %HOMEDRIVE% = the root folder of your system partition
    %APPDATA% = the application data folder for each user
    %HOMEPATH% = your user folder
    %PUBLIC% = your public folder
    %SYSTEMROOT% = windows folder
    %PROGRAMFILES% = program files folder
    %TEMP% = user's temp folder

    and I'm sure there are more...
      My Computer


  3. Posts : 759
    Windows 7 Enterprise x64
    Thread Starter
       #3

    CommonTater said:
    Hi Max... why would you do that?
    Becuase it's simple, and that's the way I've always done it. Except now I have a .reg file I just double-click on after a clean install. It's among a number of .reg files I use.
      My Computer


  4. Posts : 1,170
    XP Pro SP3 X86 / Win7 Pro X86
       #4

    MadMaxData said:
    CommonTater said:
    Hi Max... why would you do that?
    Becuase it's simple, and that's the way I've always done it. Except now I have a .reg file I just double-click on after a clean install. It's among a number of .reg files I use.
    Yeah, well... My way is better...

    Hey... whatever works.
      My Computer


  5. Posts : 536
    Windows 7
       #5

    Also, if you put whatever paths you need in your PATH environment variable, then that will negate the need to have CMD in a different directory in most cases. It won't really matter what directory it defaults to unless you are specifically trying to do something in that directory.
      My Computer


  6. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #6
      My Computer


  7. Posts : 759
    Windows 7 Enterprise x64
    Thread Starter
       #7

    Brink said:
    In addition to these great options:

    Open Command Window Here as Administrator
    An easy way to set the Command Prompt to open as Administrator, is to go to Start Orb>>> All Programs>>> Accessories>>> Right click the Command Prompt link>>> Choose Properties>>> Click on Advanced in the Shortcut tab>>> Tick the box to run as Administrator>>> click ok twice to save your setting.

    I always run the Command Prompt as Administrator. There's no reason to run it any other way.
      My Computer


  8. Posts : 18
    Windows 7 32 bit & Windows 7 64 bit
       #8

    There is another way to script this into a batch file...


    I found this result by google so, sorry for bringing this out of the archive. I thought you all would like this,

    To List the working directory, you can call on the environmental variable of %cd%

    For example:
    If your trying to make a batch file that copyies a file from a "flash drive" to the desktop, you would normally put something like this:

    copy e:\filename.txt c:\users\username\desktop /y

    The problem would then be that if you plug the flash drive into a machine where the drive letter E: is taken, your copy command would not work. If you use environmental variables your copy command would look something like this.

    copy %cd%filename.txt %userprofile%\desktop /y

    P.S. keep in mind if you would like to add in a little debugging, add "&&" to specify an action if sucessful OR "||" to specify an action if NOT successful.

    For Example the following would copy the file and if it was NOT successful it would ECHO Copying Failed.

    copy %cd%filename.txt %userprofile%\desktop /y||ECHO Copying Failed
      My Computer


  9. Posts : 18
    Windows 7 Pro 64-bit
       #9

    I came upon this thread when trying to find how to open, from a desktop icon, a Command Prompt window in a directory of my choosing.

    It would seem that the specification of a directory path in the "Start in" field in the shortcut will work only when the Command Prompt shortcut is run in normal, or non-elevated, mode.

    However, if the box "Run as administrator" is ticked, the Command Prompt window starts with C:\Windows\System32 as the current directory. It is at this point that one needs to use MadMaxData's original Regedit hack, the first post in this thread, to change this to the directory of one's choosing, say D:\MyDirectory - for which I thank him!
      My Computer


  10. Posts : 18
    Windows 7 Pro 64-bit
       #10

    I came upon this thread when trying to find how to open, from a desktop icon, a Command Prompt window in a directory of my choosing.

    It would seem that the specification of a directory path in the "Start in" field in the shortcut will work only when the Command Prompt shortcut is run in normal, or non-elevated, mode.

    However, if the box "Run as administrator" is ticked, the Command Prompt window starts with C:\Windows\System32 as the current directory, regardless of whatever directory path has been put in the "Start in" field. It is at this point that one needs to use MadMaxData's original Regedit hack, the first post in this thread, to change this to the directory of one's choosing, say D:\MyDirectory - for which I thank him!
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:32.
Find Us