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.

Isaz
  • 141
  • 1
  • 1
  • 6

3 Answers3

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
grawity
  • 501,077
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.

Greg W
  • 1,123
4

Just type the drive letter

C:\Users>K:
Rajiv
  • 141