If you need to obtain a list of all disk drives on a Microsoft Windows system
from a
command line interface (CLI), e.g., a command prompt window, you can do so using
Windows Management Instrumentation Command-line (WMIC). You can obtain
a list of drives by opening a
command prompt window and then issuing a wmic logicaldisk get
command followed by parameters relevant to the information you
wish to see. You can see a list of parameter options by issuing the command
wmic logicaldisk get /?
.
C:\>wmic logicaldisk get /? Property get operations. USAGE: GET [<property list>] [<get switches>] NOTE: <property list> ::= <property name> | <property name>, <property list> The following properties are available: Property Type Operation ======== ==== ========= Access N/A N/A Availability N/A N/A BlockSize N/A N/A Caption N/A N/A Compressed N/A N/A ConfigManagerErrorCode N/A N/A ConfigManagerUserConfig N/A N/A Description N/A N/A DeviceID N/A N/A DriveType N/A N/A ErrorCleared N/A N/A ErrorDescription N/A N/A ErrorMethodology N/A N/A FileSystem N/A N/A FreeSpace N/A N/A InstallDate N/A N/A LastErrorCode N/A N/A MaximumComponentLength N/A N/A MediaType N/A N/A Name N/A N/A NumberOfBlocks N/A N/A PNPDeviceID N/A N/A PowerManagementCapabilities N/A N/A PowerManagementSupported N/A N/A ProviderName N/A N/A Purpose N/A N/A QuotasDisabled N/A N/A QuotasIncomplete N/A N/A QuotasRebuilding N/A N/A Size N/A N/A Status N/A N/A StatusInfo N/A N/A SupportsDiskQuotas N/A N/A SupportsFileBasedCompression N/A N/A VolumeName N/A N/A VolumeSerialNumber N/A N/A The following GET switches are available: /VALUE - Return value. /ALL(default) - Return the data and metadata for the attribute. /TRANSLATE:<table name> - Translate output via values from <table name>. /EVERY:<interval> [/REPEAT:<repeat count>] - Returns value every (X interval) se conds, If /REPEAT specified the command is executed <repeat count> times. /FORMAT:<format specifier> - Keyword/XSL filename to process the XML results. NOTE: Order of /TRANSLATE and /FORMAT switches influences the appearance of outp ut. Case1: If /TRANSLATE precedes /FORMAT, then translation of results will be follo wed by formatting. Case2: If /TRANSLATE succeeds /FORMAT, then translation of the formatted results will be done. C:\>
For example, the results from issuing the command on a Windows 10 system to display the device ID, volume name, and description are shown below:
C:\>wmic logicaldisk get deviceid, volumename, description Description DeviceID VolumeName Local Fixed Disk C: OS CD-ROM Disc D: CD-ROM Disc E: Removable Disk F: EMTEC C:\>
In the above example, drive C: is the internal disk drive in the system and drive F: is an 8 GB USB 2.0 flash drive. If I only want to see a particular type of drive, e.g., only internal disk drives or only removeable USB-attached drives, I can add a "where" argument to the command and specify a drive type. The values that can be used to specify drive types are shown below:
Value | Description |
---|---|
0 | Unknown |
1 | No Root Directory |
2 | Removable Disk |
3 | Local Disk |
4 | Network Drive |
5 | Compact Disc |
6 | RAM Disk |
For instance, if I only wanted to see local disks, e.g., the internal disk drive in the system, I could use the command below, which would only show drive C:
C:\>wmic logicaldisk where drivetype=3 get deviceid, volumename, description Description DeviceID VolumeName Local Fixed Disk C: OS C:\>
If I only wanted to see removable disks, such as USB flash drives, attached to the system, I could use the command below:
C:\>wmic logicaldisk where drivetype=2 get deviceid, volumename, description Description DeviceID VolumeName Removable Disk F: EMTEC C:\>
If I use a drive type of 5, instead, I should see compact disc (CD) drives.
C:\>wmic logicaldisk where drivetype=5 get deviceid, volumename, description Description DeviceID VolumeName CD-ROM Disc D: CD-ROM Disc E: C:\>
In the example above, thought the output shows two CD-ROM drives, the system doesn't actually have any CD-ROM drives in it nor externally attached to it. Instead, an Android phone is connected to the Dell laptop by a USB cable and is being reported as drives D: and E:, though if I attempt to view the contents of those drives, I see "the device is not ready."
C:\>dir d: The device is not ready. C:\>dir e: The device is not ready. C:\>
You can, of course, specify other parameters on the command line. E.g.,
you can request the media type be displayed by including mediatype
as a parameter. The output will then show the type of media currently
present in the logical drive. The value may not be exact for removable drives
if currently there is no media in the drive. E.g.:
C:\>wmic logicaldisk where drivetype=2 get deviceid, volumename, description, mediatype Description DeviceID MediaType VolumeName Removable Disk F: EMTEC C:\>wmic logicaldisk where drivetype=3 get deviceid, volumename, description, mediatype Description DeviceID MediaType VolumeName Local Fixed Disk C: 12 OS C:\> C:\>wmic logicaldisk where drivetype=5 get deviceid, volumename, description, mediatype Description DeviceID MediaType VolumeName CD-ROM Disc D: 11 CD-ROM Disc E: 11 C:\>
The media type values are listed below:
5 1/4-Inch Floppy Disk - 1.2 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 1.44 MB -512 bytes/sector
3 1/2-Inch Floppy Disk - 2.88 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 20.8 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 720 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 360 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 320 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 320 KB - 1024 bytes/sector
5 1/4-Inch Floppy Disk - 180 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 160 KB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 120 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 640 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 640 KB - 512 bytes/sector
5 1/4-Inch Floppy Disk - 720 KB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 1.2 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector
5 1/4-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector
3 1/2-Inch Floppy Disk - 128 MB - 512 bytes/sector
3 1/2-Inch Floppy Disk - 230 MB - 512 bytes/sector
8-Inch Floppy Disk - 256 KB - 128 bytes/sector
Related articles:
References: