CPU serial number / motherboard serial number using C#

3.8k views Asked by At

I am using this piece of code to get the CPU / motherboard serial number:

macid = AuraRijndael.GetMacID();
ManagementObjectCollection mbsList = null;
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
mbsList = mbs.Get();
foreach (ManagementObject mo in mbsList)
{
    id = mo["ProcessorID"].ToString();
}

ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
ManagementObjectCollection moc = mos.Get();
foreach (ManagementObject mo in moc)
{
    motherBoard = (string)mo["SerialNumber"];
}

But it doesn’t work on some machines. On a Lenovo it works fine, but on others it doesn't. Is there a foolproof way of getting the CPU / motherboard serial number?

Are there machine specific unique id generation mechanisms possible that is also reliable? (I would appreciate any examples.)

0

There are 0 answers