fmwebschool
asked on
Retrieve Unique ID Number of Thumb Drive
Using a .bat file and the command line, (Windows XP) I have been asked to try to get the ID# off of a USB thumb drive. I know how to do this for the hard drive, but now my client wants the unique identifier off of a thumb drive.
Plug your USB in any PC, then download and save SIW program in your C:
Double click on the program, locate storage devices. Under interface tab, you will see USB and its ID
http://www.shareup.com/SIW-download-23742.html
K
Double click on the program, locate storage devices. Under interface tab, you will see USB and its ID
http://www.shareup.com/SIW-download-23742.html
K
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much for the code!
ASKER
Hi Graye,
Recently you posted on Experts exchange code to retrieve the volume serial number of a thumbdrive - your code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
Wscript.Echo "------------------------- ---------- "
Wscript.Echo "Win32_LogicalDisk instance"
Wscript.Echo "------------------------- ---------- "
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "DriveType: " & objItem.DriveType
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Wscript.Echo "VolumeName: " & objItem.VolumeName
Wscript.Echo "VolumeSerialNumber: " & objItem.VolumeSerialNumber
Is it posible to retrieve the actual hardware serial number of the parent device for that volume? That would be amazingly helpful!
Thank you so much for your time, and any guidance you can give.
In Kindness
Stephen K Knight
Recently you posted on Experts exchange code to retrieve the volume serial number of a thumbdrive - your code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
Wscript.Echo "-------------------------
Wscript.Echo "Win32_LogicalDisk instance"
Wscript.Echo "-------------------------
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "DriveType: " & objItem.DriveType
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Wscript.Echo "VolumeName: " & objItem.VolumeName
Wscript.Echo "VolumeSerialNumber: " & objItem.VolumeSerialNumber
Is it posible to retrieve the actual hardware serial number of the parent device for that volume? That would be amazingly helpful!
Thank you so much for your time, and any guidance you can give.
In Kindness
Stephen K Knight
That's bit more complicated to do... it takes a lot of low-level programming to get the "String Descriptor" from the USB Device Driver. Also not all usb devices support serial numbers.
About the best you can do is to use the identifier that Microsoft generates during it's Plug and Play negotiation. It is generally understood (but not documented) that the PnPDeviceID is generated the same way on all PCs and all versions of Windows.
Take a look at the PnPDeviceIDs of two "identical" USB devices, notice where the values differ:
PNPDeviceID: USBSTOR\DISK&VEN_&PROD_USB _FLASH_MEM ORY&REV_6. 50\03716B6 0A130B8F8& 0
PNPDeviceID: USBSTOR\DISK&VEN_&PROD_USB _FLASH_MEM ORY&REV_6. 50\0B317B6 080E24882& 0
^^^^^^^^^^^^^
Although technically, the "03716B60A130B8F8" and "0B317B6080E24882" values are not the device serial number, they will probably do in your case.
You'd get the PnPDeviceID from the "raw" disk drive using the Win32_DiskDrive class
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_DiskDrive",,48)
For Each objItem in colItems
Wscript.Echo "------------------------- ---------- "
Wscript.Echo "Win32_DiskDrive instance"
Wscript.Echo "------------------------- ---------- "
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "InterfaceType: " & objItem.InterfaceType
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "Model: " & objItem.Model
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Next
About the best you can do is to use the identifier that Microsoft generates during it's Plug and Play negotiation. It is generally understood (but not documented) that the PnPDeviceID is generated the same way on all PCs and all versions of Windows.
Take a look at the PnPDeviceIDs of two "identical" USB devices, notice where the values differ:
PNPDeviceID: USBSTOR\DISK&VEN_&PROD_USB
PNPDeviceID: USBSTOR\DISK&VEN_&PROD_USB
^^^^^^^^^^^^^
Although technically, the "03716B60A130B8F8" and "0B317B6080E24882" values are not the device serial number, they will probably do in your case.
You'd get the PnPDeviceID from the "raw" disk drive using the Win32_DiskDrive class
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_DiskDrive",,48)
For Each objItem in colItems
Wscript.Echo "-------------------------
Wscript.Echo "Win32_DiskDrive instance"
Wscript.Echo "-------------------------
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "InterfaceType: " & objItem.InterfaceType
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "Model: " & objItem.Model
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Next
http://today.java.net/pub/a/today/2006/07/06/java-and-usb.html