Reputation: 813
How do I change default startup directory for command prompt in Windows 7?
I usually do the following to start command prompt from C:\
WIN-R (Run Prompt) cmd /K cd C:\
I want to do the following to start command prompt from C:\
WIN-R (Run Prompt) cmd
Upvotes: 81
Views: 236526
Reputation: 13
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
is no longer valid.
The new key is here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
Change "Autorun" to "CD /d C:\YourFolder" (without double quotes)
Upvotes: 0
Reputation: 101569
While adding a AutoRun entry to HKEY_CURRENT_USER\Software\Microsoft\Command Processor
like Shinnok's answer is the way to go it can also really mess things up, you really should try to detect a simple cmd.exe startup vs a script/program using cmd.exe as a child process:
IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:\)
Upvotes: 32
Reputation: 2234
Use Windows Terminal and configure a starting directory.
Partial settings.json
:
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false,
"startingDirectory": "C:\\DEV"
},
Upvotes: 0
Reputation: 610
I think the easiest way is to make a cmd
shortcut, then change the shortcut's "Start in" directory to the one you want to start with.
Upvotes: 4
Reputation: 1
In the new Windows Terminal, you can click Settings and edit the line "startingDirectory" to achieve something similar.
Please note, however, that this changes the default startup directory only in Windows Terminal, and not for the command prompt globally.
Upvotes: 0
Reputation: 6949
Edit: It actually seems that editing the file shortcut breaks the Win+x, c key shortcut. (Moral of the story: only change system files you know how to fix! Eventually after a Windows update it repaired itself.)
What I ended up doing is creating a new customized Command Prompt shortcut in the start folder and pinned to the taskbar that I launch instead of cmd.exe
As other answers point out, changing the registry Autorun cmd start location is a bad idea because it silently will break other programs that shell out for tasks, like Visual Studio Code.
You should just change whatever shortcut you use to open cmd to have a Start In entry.
If you use Win+x, c to launch cmd, you can edit the Start In for
"%LOCALAPPDATA%\Microsoft\Windows\WinX\Group3\02 - Command Prompt.lnk"
Upvotes: 1
Reputation: 23
hi if you want cmd to automatically open when the machine starts up you can place the cmd.exe executable in the startup folder(just search for startup and place a shortcut of cmd.exe there)
Upvotes: -1
Reputation: 3673
My default dir was system32 when starting CMD. I then created a batch file in that directory to change dir to the one I was after.
This caused me to always call that bat when starting CMD every time. So I made a reg file & put this inside:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"Autorun"="cd C:\\Users\\Me\\SomeFolder"
After saving it, I opened the file, clicked ok to merge with registry, and since then every time I open CMD, I get my dir
Upvotes: 0
Reputation:
On windows 7:
Every time you click on the cmd in your start menu or your desktop shortcut, the CMD will open in your default location
Upvotes: 2
Reputation: 1518
Upvotes: 26
Reputation: 21
it looks something like this :
Upvotes: 1
Reputation: 11
One easy way to do it + bonus.
Start cmd
with administrator rights, the default directory for the prompt will be C:\WINDOWS\system32
.
I created a bat file in that directory (notes.bat
)
Opened it with notepad and wrote the following lines. Each line is followed with a comment which should not be added to the bat file.
@echo off
prompt $S$CYourNamel$F$S$G$S
/* This is a comment, do not include it in the bat file - above line will make the prompt look like (YourName) > */
cd C:\Your_favorite_directory
/* This is a comment, do not include it in the bat file - above line will navigate you to your desired directory */
Saved the file and that was it.
Now when You open cmd
with admin rights, just write: notes
or notes.bat
and it will execute the notes.bat
file with desired changes.
Upvotes: 1
Reputation: 9
"start in directory" command
cmd /K cd C:\WorkSpace
but if WorkSpace happens to be on different than C drive, console will be launched in default folder and then you still need to put D: to change drive To avoid this use cd with -d parameter
cmd /K cd -d D:\WorkSpace
create a shortcut and your fixed ;)
Upvotes: -1
Reputation: 11
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
string: Autorun value: cd /d %~dp0
all bat files will run from the bat file location
Upvotes: 1
Reputation: 9
type
cmd.exe /k cd c:/
in a text file and save as cmd.bat Clicking this file does the trick. You can pin it to the start menu as well.
To start in a partitioned drive (e.g. D), use
cmd.exe /k d:
Upvotes: 0
Reputation: 1
regedit worked great. HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\Command
Processor, all you have to do is change the AutoRun key value, which is already set to wherever you are currently getting dumped into to a new value in the format of:
cd /d <drive:path>
for c:\, that would be cd /d c:\
for junk, that would be cd d/ c:\junk
its very simple, even a novice thats never used regedit should be able to figure it out. if not, go to the c:\prompt and just type in regedit, then follow the path to the key.
Upvotes: -3
Reputation: 61
Bit late but ignore the registry mods. Simply change the shortcut target to:
cmd /k "command"
i.e.
cmd /k "cd\myStartUpFolder"
Voila!
Upvotes: 6
Reputation: 3425
Make a shortcut pointing to cmd.exe somwhere (e.g. desktop) then right-click on the copy and select "properties". Navigate to the "Shortcut" menu and change the "Start in:" directory.
Upvotes: 106
Reputation: 659
The following solution worked well for me. Navigate to the command prompt shortcut in the start menu:
C:\Users\ your username \AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt
Right click on the shortcut file to open the properties dialog. Inside the "Start in:" textbox you should see %HOMEDRIVE%%HOMEPATH%. If you want the prompt to start in C:\ just replace the variables with "C:\" (without quotes).
update
It appears that Microsoft has changed this behavior recently and so now an additional step is required. After performing the steps above copy the modified shortcut "Command Prompt" and rename it to "cmd". Then when typing "cmd" in the start menu it should once again work.
Upvotes: 53
Reputation: 1
Keep the opening of the command prompt clean. Avoid editing the registry key and adding an Autorun, it may come back to bite you.
Create a simple batch file and save it in the C:\Windows or C:\Windows\System32 folder. I call mine !.bat (exclamation mark). It has the following commands:
@echo off c: cd \ cls whoami
It goes to the folder where I need to work, clears the screen and tells me what security context I'm in.
Upvotes: -1
Reputation: 81
On Windows Start Menu, right click on Command Prompt.
Click on "Properties".
"Command Prompt Properties" dialog box opens.
Edit the field "Start in " to a location where you want to start the command prompt.
Example: Chand %HOMEDRIVE%%HOMEPATH% to D:\PersonalPrograms.
Next time when you start command prompt the start up directory will be D:\PersonalPrograms
Upvotes: 8
Reputation: 11
changing shortcut under Windows System on 8.1 worked for me - another thing I found is that 'Start In:' WORKS when Advanced -> Run as admin is UNCHECKED, however, if CHECKED, it does not work
Upvotes: 1
Reputation: 653
This doesn't work for me. I've tried this both under Win7 64bit and Vista 32.
I'm using the below commandline to add this capability.
reg add "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "IF x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:)"
Upvotes: 5
Reputation: 6389
Open regedit and browse to this path
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Create new string vale named Autorun
. Set its value to cd /d C:\
.
Run cmd again. Voila!
Upvotes: 42