Get disk and partition numbers for drive letter via WMI

  • Thread starter Thread starter Computer Guru
  • Start date Start date
C

Computer Guru

If I query WMI for mounted drives of type 3 (physical hard drives)
and
end up with a letter (like D:), how can I use WMI to get the correct
corresponding partition and drive values for drive D:\ ?

Is it possible to even get the entire ARC path from there?
AS in, multi(w)disk(x)rdisk(y)partition(z)


That would be nice, but I'm willing to settle for just rdisk() and
partition() (basically the drive number and the partition number)


Thanks!
 
Once you get you physical drive you get it's associating partitions, which
will look like something like this if you have 2 partitions:

WQL Query: associators of {Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"}

Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
Win32_DiskPartition.DeviceID="Disk #0, Partition #1"
 
Back
Top