How are devices identified uniquely?
Friends
I am working on a project which requires detection of USB devices.
For this i am using WMI and using the class Win32_USBHub.
This class returns many properties like Device_ID, DESCRIPTION, Name etc.
but i would like to know how windows actually identifies a device.
For eg :- pen drive, keyboards, mouse, digital cameras etc.
Description for Pen Drive and Digital Camera gives "Mass storage device" .
So i cannot use Description property
Problem with Device_ID is every pen drive has got different Device_ID.
I want something that will uniquley address a pen drive device irrespective of their device_id.
Please help...
(Note:- solution in WMI is preferable)
THANK YOU
Re: How are devices identified uniquely?
Here is the WMI code to detect the USB controllers/devices on your system. It was generated by Scriptomatic v2 from MS that you can download for free.
Note the results from my system is trimmed down to remove the controllers and I only left the device - my Sony digital camera. It specifies "REMOVABLEMEDIA" as a type. I didnt get my pen drive out for the test but I would think it would show as different. Maybe I'll try it now.
VB Code:
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("VBGURU")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "AccessState: " & objItem.AccessState
WScript.Echo "Antecedent: " & objItem.Antecedent
WScript.Echo "Dependent: " & objItem.Dependent
WScript.Echo "NegotiatedDataWidth: " & objItem.NegotiatedDataWidth
WScript.Echo "NegotiatedSpeed: " & objItem.NegotiatedSpeed
WScript.Echo "NumberOfHardResets: " & objItem.NumberOfHardResets
WScript.Echo "NumberOfSoftResets: " & objItem.NumberOfSoftResets
WScript.Echo
Next
Next
VB Code:
AccessState:
Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24D2&SUBSYS_80A61043&REV_02\\3&267A616A&0&E8"
Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\\DISK&VEN_SONY&PROD_SONY_DSC&REV_4.50\\6&35C56897&0"
NegotiatedDataWidth:
NegotiatedSpeed:
NumberOfHardResets:
NumberOfSoftResets:
AccessState:
Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24D2&SUBSYS_80A61043&REV_02\\3&267A616A&0&E8"
Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\\REMOVABLEMEDIA\\7&5D1629E&0&RM"
NegotiatedDataWidth:
NegotiatedSpeed:
NumberOfHardResets:
NumberOfSoftResets:
Re: How are devices identified uniquely?
Ok here it is for my jump drive or pen drive. There is an identifier between the 2.
VB Code:
AccessState:
Antecedent: \\VBGURU28\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24DD&SUBSYS_80A61043&REV_02\\3&267A616A&0&EF"
Dependent: \\VBGURU28\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\\DISK&VEN_&PROD_USB_DISK_PRO&REV_1.13\\483619010A5B&0"
NegotiatedDataWidth:
NegotiatedSpeed:
NumberOfHardResets:
NumberOfSoftResets:
AccessState:
Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24DD&SUBSYS_80A61043&REV_02\\3&267A616A&0&EF"
Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\\REMOVABLEMEDIA\\7&D5604D5&0&RM"
NegotiatedDataWidth:
NegotiatedSpeed:
NumberOfHardResets:
NumberOfSoftResets:
Re: How are devices identified uniquely?
I am sorry, but i donot understand what is happening???
I would be gr8ful if u could explain me what is going on???
Why do u need an array in the first place?
By the way which property is giving u removable media???
Thank you