0
C:\Users\vk Yadav>cd d:
D:\ 
C:\Users\vk Yadav>

Why it's happening?

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • @Stephan, is it possible you rather change your colure link to point directly to your answer in that link? I do not completely agree to the `D:` standalone command as demonstrated in my answer and yours in the link. – Gerhard Aug 22 '20 at 07:35
  • 1
    @Gerhard: I did (https://stackoverflow.com/a/17754694/2152082). It seems, SO has changed the Duplicate-Feature to only be able to point to questions, not answers anymore (like I'm used to). What a pity - I too disagree with the accepted answer there (it works, but it isn't the most elegant solution). – Stephan Aug 22 '20 at 07:41
  • Ok thank you @Stephan, I suppose The link you have in the comment is sufficient. – Gerhard Aug 22 '20 at 07:43

3 Answers3

0

type D: and press enter. so you can move to D drive

Harish Mahajan
  • 3,254
  • 4
  • 27
  • 49
0

cd means change directory. You don't use it to change drives. Typing cd D: tells you what the current directory is on drive D:.

To change drives, just type the new drive letter followed by :, as in D: and hit Enter.

To learn what cd does, type cd /? at a command prompt.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Yes.. however, if you were previously in `D:\Program Files\Acrobat"` doing just `D:` will land you back in `D:\Program Files\Acrobat"` which would require a new command `cd \` to land exactly in the intended path. – Gerhard Aug 22 '20 at 07:15
  • Apologies, That last part in my comment was meant to be cd \ – Gerhard Aug 22 '20 at 07:28
0

Reading cd /? help shows you that when changing directories to different drives requires /d option.

cd /d D:\

but using

cd /d D:

will only change to the drive with previous path, similar as standalone D: command

The command obviously works with appended folders.

cd /d "D:\Some Folder\"

If you only want to changes drives, then just doing

D:

Will change to the drive. But if you were in a specific directory on D: prior to swopping to C:\ then running D: will land you back in that dir. The following demonstrates this, you can test it yourself by copying it, add an actual directory name where I have Some Folder and paste into your cmd window.

echo off & cls
cd "%userprofile%"
cd
cd /d "D:\Some Folder\"
cd
D:
cd
C:
cd
cd /d D:
cd
cd /d C:
cd
cd /d D:\
cd
cd /d C:\
cd

Running the above on my system (note I use Z:\ instead of D:\) enter image description here

So if you intend to only land exactly on the drive or drive\dir, then just use cd /d path

Gerhard
  • 22,678
  • 7
  • 27
  • 43