If you're like me then you work from the command-line a lot of the time. One frustration I have with Windows is when I'm doing something at the command line, plug a flash drive into a USB port, and need to know what drive letter the flash drive has been assigned by Windows. Of course, I could easily do this by leaving the command line and opening Computer from the Start menu, but I'd like to figure this out without having to leave the command line. Is this possible?
Yes it is, and one way of doing it is to use the Windows Management Instrumentation Command-line utility or WMIC. To do this, open a command prompt window and run the following command:
wmic logicaldisk get caption,description,filesystem
Here's the output of this command when I ran it on a Windows 7 computer right after I plugged a flash drive into it:
Caption Description FileSystem
C: Local Fixed Disk NTFS
D: CD-ROM Disc
E: CD-ROM Disc
F: Removable Disk
G: Removable Disk
H: Removable Disk
I: Removable Disk
J: Removable Disk FAT
Clearly the flash drive is drive J on the computer, but what about volumes F through I? These all have Removable Disk for the Description field, but the FileSystem field for these drives is null—why? Well, this particular computer happens to be a repurposed HP Media Center so it has a lot of slots on it for connecting removable storage devices and cards, but no devices are connected to these slots so they show up as having no file system on them. So drive J is definitely my flash drive.
Mitch Tulloch is a seven-time recipient of the Microsoft Most Valuable Professional (MVP) award and widely recognized expert on Windows administration, deployment and virtualization. For more tips by Mitch you can follow him on Twitter or friend him on Facebook.