105

Possible Duplicate:
Using cd Command in Windows Command Line, Can't Navigate to D:\

I am unable to cd D:\ or cd D: or to any other drives. I am facing this problem from last 2 months but until now cmd was not that important to me.

I have checked multiple times with 2-3 anti-virus but it doesnt show any, and according to me there shouldnt be, because I visit only a few top sites, use genuine software and plug only my usb drive in PC.

This is what happens when I try to cd
cmd screenshot

5
  • 1
    While the question has been answered, a neat upshot of this is that different drives maintain different working directories - and you can refer to them by the drive letter! copy aFile e: will copy aFile to e:'s working directory, for example.
    – Phoshi
    Jun 26, 2011 at 22:07
  • The irony, Phoshi, is that in Windows NT, including Windows NT version 6.1 as in the question, that is not the case for the operating system proper. There's only one current directory for a process. The old MS/PC/DR-DOS semantics of separately maintained working directories for each drive are emulated (but not exactly) via a system of hidden environment variables.
    – JdeBP
    Jun 27, 2011 at 10:48
  • It is indeed true, that there are (even if emulated) multiple current directories. For further information read this nice article blogs.msdn.com/b/oldnewthing/archive/2010/10/11/10073890.aspx by Raymond Chen
    – HalloDu
    Jun 27, 2011 at 13:28
  • It’s not surprising or ironic, it’s because Windows and DOS have completely different interfaces. Yes every process (even in DOS) gets a single item in response to a GWD command, but otherwise Windows and DOS function very differently. You can’t printf from a non-console Windows program either. ;-)
    – Synetech
    Jun 28, 2011 at 0:45
  • 1
    cd /d "D:\path"
    – T.Todua
    Jun 3, 2020 at 10:59

2 Answers 2

186

You do not need to cd d:\ just enter d:.

CD stands for change directory, which is not what you want to do.

5
  • Thanks just realized I need to throw away ui for few days
    – Shishant
    Jun 26, 2011 at 19:37
  • 4
    > CD stands for change directory, which is not what you want to to. Except that in Windows, the CD command does have an option to change drive.
    – Synetech
    Jun 26, 2011 at 21:30
  • @Synetech, that feature is recent in the history of Dos and Windows. It isn't in any version of COMMAND.COM, for example. My shaky recollection is that it wasn't in the earliest CMD.EXE from NT 3.1 either, but I can't put my hands on documentation to prove that easily right now.
    – RBerteig
    Jun 26, 2011 at 22:11
  • 3
    It’s not that recent; it’s in at least W2K. Regardless, the question is about Windows 7, so command.com is irrelevant and the /d switch is definitely there.
    – Synetech
    Jun 26, 2011 at 22:16
  • 1
    @Berteig, that feature is recent in the history of Dos and Windows. It isn't in any version of COMMAND.COM, for example Also, the OP wasn’t using DOS, the question is about Windows 7, so the history of CD was irrelevant here; that switch was available.
    – Synetech
    Nov 30, 2013 at 16:06
67

Use one of the following:

C:\Ruby\bin> cd /d D:\
D:\>

or

C:\Ruby\bin> cd D:\
C:\Ruby\bin> D:
D:\>
8
  • 7
    And, don't forget put " around path if there are spaces in it: cd "D:\My Documents\My Music\A Band\An Album" Jun 26, 2011 at 19:27
  • 3
    @Liu, you don't always need to bother, for example cd /d C:\program files\Microsoft Office works fine for me from D: on a Win XP cmd instance. It is however, a really good habit to get in to, otherwise one day you'll use another application that cannot handle paths given as arguments that aren't enclosed.
    – DMA57361
    Jun 27, 2011 at 10:23
  • That works because the CD command expects a single path argument (it does not take multiple directories). Therefore it interprets everything (other than the /d switch) as a single path, including spaces. That’s why if you use the auto-completion character (defaults to TAB) with CD, it only selects directories, while with other commands (eg dir, copy, etc.), it selects files and directories together. Like DMA57361 said, CD knows what it does and understands its arguments, so it handles them— or rather it —intelligently. (Were that all programs would do so. *sigh*)
    – Synetech
    Jun 28, 2011 at 0:35
  • Ah, see Raymond says the same thing in the blog entry that HalloDu links to above.
    – Synetech
    Jun 28, 2011 at 0:46
  • 1
    cd /d "D:\abc\your_directory"
    – Larry Lo
    Sep 19, 2019 at 9:45

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