Discussion:
Get disk and partition numbers for drive letter via WMI
(too old to reply)
Computer Guru
2007-06-28 05:52:43 UTC
Permalink
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!
Jonathan Liu [MSFT]
2007-08-07 21:14:14 UTC
Permalink
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"
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--
Post by 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!
Loading...