Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Disk Number and Moint Point

Status
Not open for further replies.

cluM02

Programmer
Jul 23, 2013
1
US
Hello,

I found a script code below from the post at about converting logical disk to physical disk.
I need the code to the convert the logical disk to physical disk number and the mount associated with the disk number.

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
 
For Each objDrive In colDiskDrives
    Wscript.Echo "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID 
    strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
    Set colPartitions = objWMIService.ExecQuery _
        ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
            strDeviceID & """} WHERE AssocClass = " & _
                "Win32_DiskDriveToDiskPartition")
 
    For Each objPartition In colPartitions
        Wscript.Echo "Disk Partition: " & objPartition.DeviceID
        Set colLogicalDisks = objWMIService.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                objPartition.DeviceID & """} WHERE AssocClass = " & _
                    "Win32_LogicalDiskToPartition")
 
        For Each objLogicalDisk In colLogicalDisks
            If objLogicalDisk.VolumeName = "System" Then
                WScript.Echo "Logical Disk: " & objLogicalDisk.DeviceID
            End If
        Next
        Wscript.Echo
    Next
    Wscript.Echo
Next

I like to know if there is any way this code can edited to get the mount point associated with the disk number.

I appreciate very much for any suggestion or directions.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top