2

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.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NRB
  • 95
  • 1
  • 7
  • 1
    Try updating motherboard driver/software from vendor webpage. It should be added into the registry. See : https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor – jdweng Jul 23 '20 at 11:26
  • 2
    a foolproof way? no. (even when not considering the fact that _nothing_ is foolproof; the universe always creates a bigger fool) – Franz Gleichmann Jul 23 '20 at 11:30
  • 1
    WMI is probably the best place to look, but the information is not standardized and up to each manufacturer. In my experience, this kind of thing is an exercise in handling every case you know of in advance with vendor or model specific logic. See also: https://stackoverflow.com/questions/23675550/motherboard-id-wmi-c-reliable – Noah Stahl Jul 25 '20 at 16:41
  • 1
    For SerialNumber, it's usually not due to the OS, but to the manufacturer. Many (especially the ones who don't sell to enterprises) just don't add serial numbers to their hardware (it requires more work/cost as each piece must be different obviously). – Simon Mourier Jul 25 '20 at 16:52
  • The only thing that reliably works is the Mac ID. You get the mac ID every time. – NRB Jul 27 '20 at 17:39

0 Answers0