20

Possible Duplicate:
Using cd Command in Windows Command Line, Can’t Navigate to D:\
CMD cd to other drives except C:\ not working

I am working with cmd.exe on Windows 7 (as opposed to Powershell). I have 2 partitions on my drive, C contains the OS and installed programs, and D contains my data. I was trying to cd from C to D, but cmd wouldn't let me:

C:\>cd D:\

C:\>

However, when I type dir D:\, it will list the contents of D correctly. Why does it do this and how can I fix it? Powershell works fine so I can use that, but I would like to know what makes cmd misbehave.

2
  • Could someone make an msdos tag? I think this question is valid for all versions of DOS from 1.0 and up. If I recall correctly CP/M didn't have this concept but you could address the separate drives by prepending the driveletter: to the file name. I think this is important as this is a valid question for someone who didn't live through the DOS era and not a Windows 7 question as such. Dec 1, 2011 at 0:31
  • @StuartWoodward actually DOS 1.0 did not have subdirectories - they were introduced in 2.0. Dec 2, 2011 at 18:31

3 Answers 3

33

You have to use just d: , not cd d:\

EDIT: it is also possible to use cd /d d: to change drives using cd

7
  • I am not really sure why made that design decision, and I am looking for it, but that's just the way that it has always been.
    – soandos
    Nov 27, 2011 at 1:41
  • @astay13 see edit.
    – soandos
    Nov 27, 2011 at 1:42
  • 1
    @soandos cd stands for "change directory", and D: is a drive, not a directory. See David's answer for more details
    – Izkata
    Nov 27, 2011 at 5:56
  • @Izkata why cant you change to a directory on a different drive using the same syntax used to go to a different folder? that is what I was saying.
    – soandos
    Nov 27, 2011 at 5:58
  • It does change the directory: e.g.: C:\>cd D:\test, does change the current directory on disk D: to test, but the prompt is still on C: Nov 27, 2011 at 10:34
28

Windows tracks a separate working directory for each drive. You are currently on the 'C' drive in the working directory '\'. When you type cd d:\ it changes your working directory for the 'D' drive to '\' and has no effect on your C drive working directory. To change drives, just type D:. You can change both at the same time with the /d parameter to cd.

3
  • 3
    Actually, the Windows that the questioner says that xe is running — Windows NT 6.1 — has never — not since 1993 — had a separate working directory for each drive. There is one working directory per process. The appearance of multiple working directories across multiple drives is a fiction maintained by Microsoft's command interpreter and the runtime libraries of its languages, using hidden environment variables.
    – JdeBP
    Nov 27, 2011 at 20:33
  • 1
  • @JdeBP Hidden environment variables that track a separate working directory for each drive? And is Microsoft's command interpreter and the runtime libraries of its languages part of Windows? Feb 2, 2016 at 20:07
1

It should be noted that pushd (e.g. pushd D:\) will always change drives.

1
  • This would be wonderful as a comment to the question but doesn't answer the question. Dec 3, 2011 at 4:48

Not the answer you're looking for? Browse other questions tagged .