我正在尝试使用 WMI 调用获取驱动器接口类型和驱动器号,但驱动器号始终作为机器上最后分配的驱动器返回
任何人都可以帮忙吗?
'On Error Resume Next
Option Explicit
Dim strComputer, objWMIService, colIDiskDrive, objDiskDrive, colLogicalDisk, objLogicalDisk, strDriveLetter, strPNPDeviceID, strDiskLetter, strInterfaceType
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colIDiskDrive = objWMIService.ExecQuery("Select * from Win32_DiskDrive",,48)
For Each objDiskDrive in colIDiskDrive
strPNPDeviceID = objDiskDrive.PNPDeviceID
strInterfaceType = objDiskDrive.InterfaceType
Set colLogicalDisk = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
For Each objLogicalDisk in colLogicalDisk
strDiskLetter = objLogicalDisk.Name
Next
Wscript.Echo strInterfaceType & " " & strDiskLetter
Next