Get the hard disk hardware serial number

Terry Reedy tjreedy at udel.edu
Thu Jun 4 14:02:33 EDT 2009


Dietmar Schwertberger wrote:

> The WMI method is e.g. described here:
> http://www.velocityreviews.com/forums/t359670-wmi-help.html
> 
> 
> import wmi

Not in the stdlib, but available here:
http://pypi.python.org/pypi/WMI/1.3
and requires in turn pywin32:
http://pypi.python.org/pypi/pywin32/210

> c = wmi.WMI()
> for pm in c.Win32_PhysicalMedia():
>     print pm.Tag, pm.SerialNumber
> 
> or to retrieve the serial number for the installation drive:
> 
> serial = c.Win32_PhysicalMedia(["SerialNumber"], 
> Tag=r"\\.\PHYSICALDRIVE0")[0].SerialNumber.strip()
> 
> 
> Regards,
> 
> Dietmar




More information about the Python-list mailing list