pyt...@bdurham.com wrote:
Apparently retrieving the serial number of a USB memory stick is
much more complicated than one would think.
Is there a published Python recipe for determining a USB memory
stick's device level serial number under Windows and/or
Linux/Mac?
1. Here's a VBS script that attempts to use WMI to retrieve a USB
serial number. This script reports my USB drive as PHYSICALDRIVE4
with an empty serial number. Based on this experiment, it looks
like WMI does not have access to the information we're looking
for.
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>
TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32