Type casting in VB
-
I'm working with VBScript and WMI Win32 classes. The Win32_USBControllerDevice.Dependent property returns a reference to a CIM_LogicalDevice object. However, I am not able to (maybe because I dont know how) invoke any CIM_LogicalDevice property or method using that reference. I thought the "dot" notation would work but it gave me an error. Here is the code: (I'm trying to call the "Name" property of CIM_LogicalDevice class)
Set USB_Devices = WMI_Services.ExecQuery("Select * from Win32_USBControllerDevice") For each USB_Device in USB_Devices WScript.Echo "USB Device: " & USB_Device.Dependent.Name Next
The error I got is: "ERROR: Object required: 'USB_Device.Dependent' CODE: 800A01A8" Can someone please help? -
I'm working with VBScript and WMI Win32 classes. The Win32_USBControllerDevice.Dependent property returns a reference to a CIM_LogicalDevice object. However, I am not able to (maybe because I dont know how) invoke any CIM_LogicalDevice property or method using that reference. I thought the "dot" notation would work but it gave me an error. Here is the code: (I'm trying to call the "Name" property of CIM_LogicalDevice class)
Set USB_Devices = WMI_Services.ExecQuery("Select * from Win32_USBControllerDevice") For each USB_Device in USB_Devices WScript.Echo "USB Device: " & USB_Device.Dependent.Name Next
The error I got is: "ERROR: Object required: 'USB_Device.Dependent' CODE: 800A01A8" Can someone please help?Well, you can't use a ref: object like that, as you've already found out, since the WMI provider won't resolve reference for you. But, the CIM_LogicalDevice maps to a Win32_PnPEntity object. You can use the string that Dependant returns to get at the actual device. You'll have to parse out the DeviceID, but you can use that ID to get the appropriate Win32_PnPEntity object from WMI. RageInTheMachine9532