Windows 7 Forums Search
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7 - Change Command Prompt Default Directory

 
04-13-2010   #1


Windows 7 Enterprise x64
 
 

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 System SpecsSystem Spec
04-13-2010   #2


XP Pro SP3 X86 / Win7 Pro X86
 
 


Quote   Quote: Originally Posted by MadMaxData View Post
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 System SpecsSystem Spec
04-13-2010   #3


Windows 7 Enterprise x64
 
 


Quote   Quote: Originally Posted by CommonTater View Post
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 System SpecsSystem Spec
.


04-13-2010   #4


XP Pro SP3 X86 / Win7 Pro X86
 
 


Quote   Quote: Originally Posted by MadMaxData View Post
Quote   Quote: Originally Posted by CommonTater View Post
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 System SpecsSystem Spec
04-13-2010   #5


Windows 7
 
 


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 System SpecsSystem Spec
04-13-2010   #6


Windows 7 Ultimate x64 SP1
 
 


My System SpecsSystem Spec
05-01-2010   #7


Windows 7 Enterprise x64
 
 


Quote   Quote: Originally Posted by Brink View Post
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 System SpecsSystem Spec
02-03-2012   #8


Windows 7 32 bit & Windows 7 64 bit
 
 

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 System SpecsSystem Spec
Reply

 Change Command Prompt Default Directory problems?



Thread Tools



Similar Threads for: Change Command Prompt Default Directory
Thread Forum
Solved Cannot change drive in command prompt using CD General Discussion
Solved Command Prompt Default Properties General Discussion
Change Directory in Command Prompt Software
Change time to display OS from installation disk command prompt Installation & Setup
Command Prompt to change primary monitor? General Discussion


All times are GMT -5. The time now is 11:38 AM.



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
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30