Wednesday, July 14, 2010

Windows Command Prompt Keeps Up with One Current Directory Per Drive

Or so it seems. This is copied from a console window on a machine running Windows Server 2003:
C:\Documents and Settings\jyoung>cd E:\InetPub\web sites

C:\Documents and Settings\jyoung>cd "E:\InetPub\web sites"

C:\Documents and Settings\jyoung>cd e:
E:\InetPub\web sites

C:\Documents and Settings\jyoung>e:

E:\InetPub\web sites>
Very strange. It seems that the command prompt keeps up with the “current directory” on a per-drive basis, so that when you cd to some drive that you’re not on, it changes the “current” directory for that drive rather than _the_ current directory. Then when you change drives, it remembers what drive you changed it to previously. I did not know that.

Oddly, using the /d flag is required to change directories across drives [reference].