Changing default startup directory for command pro

2019-01-08 06:31发布

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

18条回答
爷、活的狠高调
2楼-- · 2019-01-08 06:47

Edit: It actually seems that editing the file shortcut breaks the key shortcut. (Moral of the story: only change system files you know how to fix!)


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"
查看更多
做自己的国王
3楼-- · 2019-01-08 06:49

Easiest way to do this

  1. Click "Start" and type "cmd" or "command prompt".
  2. Select Top most search application named exactly same "cmd" or "command prompt".
  3. Right Click on it and select "Send To"=>"Desktop".
  4. On Your Desktop New "cmd" Shortcut will appear
  5. Right Click on that icon and choose "properties"
  6. Popup will appear, In "Shortcut" Tab Type the new location in "Start In" option (e.g D:\xyz)
  7. Drag that icon and add/pin it in "Task Bar"
查看更多
狗以群分
4楼-- · 2019-01-08 06:52

Bit late but ignore the registry mods. Simply change the shortcut target to:

cmd /k "command"

i.e.

cmd /k "cd\myStartUpFolder"

Voila!

查看更多
贪生不怕死
5楼-- · 2019-01-08 06:52

"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 ;)

查看更多
▲ chillily
6楼-- · 2019-01-08 06:55

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.

查看更多
太酷不给撩
7楼-- · 2019-01-08 06:58

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.

查看更多
登录 后发表回答