Thursday, November 30, 2006

Windows Command Line, I thought I knew Ye

I thought I knew a lot about how the Windows XP command line emulator worked. I've written a number of fairly complex batch programs, gotten pretty comfortable with a large number of command-line programs, and just today started working with the Borland C++ Builder 5.5, a command-line compiler for 32-bit Windows applications. But that led to me learning something new and surprising about the CLI today.

I have my My Documents folder on a different partition than my Windows installation. I installed XP to C:, but set My Documents to L:, which is my /home partition for my Linux OS on the same system (installed to U:). So when I was running the C++ Builder, and had to enter in files on the /home/My Documents partition as parameters to the C++ Builder, I got sick of writing the full file path.

Because I thought I had to. Until today, I couldn't figure out how to cd to another partition on my hard drive. I didn't realize that Windows was treating the partition as a virtual drive, even though it's obviously mounted as my L:. For some reason, it didn't occur to me to change drives like you switch to a directory on a floppy disk.

But that's all I had to do. Now, I don't need to write the full file path, because I can change drives and then cd to the proper directory. I'm basically an idiot for not realizing before that:
C:\> cd L:\ wouldn't work, and I need to type:
C:\> L: to change drives, and then:
L:\> cd programming\c++\helloworld to get to the directory containing my "Hello, World" source.

Moral of the Story: For those of you out there who, like me, couldn't figure out the obvious:
  • Windows treats mounted partitions as virtual disk drives, and not mounted directories like Linux and UNIX do.
  • You consequently need to change drives in a command prompt before you can change directories.
Hope this helps, it took me too long to figure it out.

No comments: