I'm trying to get the serial number of the hard disk who host windows os in a consistant way through python calling windows cmd from subprocess
So far using :
wmic diskdrive get serialnumber,index
Which give me back something like :
Index SerialNumber
1 000000001536
0 0025_XXXX_2142_XXXX.
2 000000001536
However the first, nor the index 0 is not always the hardrive with the OS... (as mentionned in the answer in Get hard disk serial number from local disk in batch)
Is there a command to get the hard drive serial number of where is installer the Windows OS ?
Thanks,
Thanks to your suggestions :
For windows > 7, In a powershell with the SystemDrive environnement variable, the serial number of the current used os can be found with :
For older versions of windows,in cmd.exe,
wmiccan be used with :In python :
Note that calling a powershell and get-partition is fairly slow...