[python-win32] Read USB memory stick serial number

python at bdurham.com python at bdurham.com
Wed Dec 30 00:19:02 CET 2009


Tim,

Cheers for the great solution!!

Your code gives me an easy to parse string containing the same serial
number as reported by USBDeview.exe.

Thank you very much,
Malcolm

<snipped>

Try using Win32_DiskDrive instead. I'm not 100% sure (read: I'm 
about 1% sure) what constitutes the USB serial number. The only
thing I'm fairly sure about is that it's *not* the volume label.

The PNPDeviceID looks good, even if it might need a bit of parsing:

<code>
import wmi

c = wmi.WMI ()
for usb in c.Win32_DiskDrive (InterfaceType="USB"):
  print usb.PNPDeviceID

</code>

</snipped>


More information about the python-win32 mailing list