190
votes

I'm using cmd.exe (C:\WINDOWS\System32\cmd.exe) and I have to change my current directory to "D:\temp" i.e. temp folder in the D drive.

When I try to cd nothing happens.

C:\> cd D:\temp

C:\>

I don't know what else to do here. Even pressing tab key does not give any hints. I have never got the reason to use cmd.exe until now when I have to. I mostly use Linux for development.

If this helps: I'm on a remote login to another computer and D:\temp in on the remote machine, but so is C:\ where I have opened the terminal (cmd.exe).

6
only add D: or C: not required cd..marlonpya
Why is this closed as off-topic? CMD can be used in programming, for an instance related to ADB (Android debug bridge) and it can also be used to execute programs in other languages (e.g. C, Java, Python, etc). If the target is in a different drive, the command is used to open the appropriate drive. I would say it directly involves tools used in programming, as it can be used for so many different programming-related things includin, but not limited to, ADB, launching programs, etcZoe
This applies to cmd command files :) - shouldn't be off topicchris31389
Again a great example of a good question, but some programmers being way too strict or having something up their a*, which results in that a proper question gets closed as off topic or for some other reason. Happy to see the large number of upvotes.JohnAndrews

6 Answers

349
votes

The "cd" command changes the directory, but not what drive you are working with. So when you go "cd d:\temp", you are changing the D drive's directory to temp, but staying in the C drive.

Execute these two commands:

D:
cd temp

That will get you the results you want.

133
votes

Another alternative is pushd, which will automatically switch drives as needed. It also allows you to return to the previous directory via popd:

C:\Temp>pushd D:\some\folder
D:\some\folder>popd
C:\Temp>_
114
votes

cd has a parameter /d, which will change drive and path with one command:

cd /d d:\temp

( see cd /?)

1
votes

Just type your desired drive initial in the command line and press enter

Like if you want to go L:\\ drive, Just type L: or l:

0
votes
cd /driveName driveName:\pathNamw
0
votes

This is an easy way to open a specific location in cmd.

Let's say the folder you want to access is D:\Level 4 Semester 1\Labs-NLP

  1. Go to the particular directory as shown below

enter image description here

  1. Then type "cmd" in the path that has "This PC >Local Disk(D:) > Level4 Semester 1 > Labs- NLP" and press enter.

enter image description here

Then cmd will pop up with this particular directory