Why doesn't "cd D:" change the command context to D:?

Try:

cd /d d:

/d will also switch drive letters as well as directories, for other information, see cd /?


The reason Windows behaves this way, is because DOS behaved that way.

In DOS, each drive has its own current directory, and the cd command changes the current directory on a drive. If that also happens to be the current drive, then your working directory changes along with it. If you want to change the current drive, you simply specify the drive letter as a command.

Notes that Windows doesn't actually work this way anymore -- you only have one current directory at any time -- but the command shell goes to great lengths to pretend that there are still per-drive current directories. Presumably this is to preserve compatibility with existing DOS batch files.

The reason DOS works this way dates back to the very earliest versions of DOS, and CP/M before it. The gory details can be found on Raymond Chen's blog.


The straight-forward answer is that "because it is not written to work that way". Simply entering D: will do what you want.

Curiously entering cd D:\somedir will, in fact, change the current directory on D: to \data, but will not change the current command prompt to D:.