2

Not sure what might have triggered this but I have noticed that while using the command prompt in windows 10 I am unable to change the drive using the cd command for any of the drive letters other than C:. I have also noticed that the autocomplete function works just fine when trying to change directory into a specific folder from the target drive but the change in the directory just doesn't happen.

Screenshots of the Disk Management tool and actual cmd prompt commands will follow:

Disk Management

Command Prompt

This behavior does not apply to PowerShell so I can successfully change the drives.

0

3 Answers 3

19

That's normal. For historical reasons, that's just how the cd command works in Cmd.exe, because that's how it worked in MS-DOS COMMAND.COM as well. The directory change is remembered (Cmd tracks it per-drive, as did MS-DOS), but you have to switch the actual drive separately – by typing just the drive:

C:\> e: E:\> cd \fonts E:\Fonts> _ 

The opposite would also work even though it would be very un-obvious:

C:\> cd e:\fonts C:\> e: E:\Fonts> _ 

(And note that when you use e.g. cd e: in your screenshot, this doesn't change anything, rather it shows you the current directory for that drive letter.)

However, Cmd.exe has a shortcut for changing both – the /d option makes cd work sanely:

cd /d e:\fonts 

The pushd/popd commands do not require amything extra, as they weren't present in MS-DOS and aren't burdened with compatibility. (I used to use doskey aliases [=pushd $* and ]=popd a lot.)

pushd e:\fonts ... popd 
3
  • +1 for mentioning pushd / popd as these work for network drives Commented Jul 1, 2020 at 17:46
  • So you are telling me that after using windows for more than 20 years it's the first time I needed to change the drive and I've always needed to use /d in order to accomplish that? Commented Jul 1, 2020 at 20:56
  • @Isaz: ¯\_(ツ)_/¯ Commented Jul 1, 2020 at 21:40
7

cd [drive]:\directory will change the current directory “context” on that drive but won’t change to that drive itself.

If you subsequently just type [drive]:, it’ll change to that drive and remember the directory you previously “cd”’ed into.

CMD has always behaved like this.

PowerShell’s “cd” is an alias to Set-Location, which always changes the current drive as well as directory.

0
4

Just type the drive letter

C:\Users>K: 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.