title: CPU serial number / motherboard serial number using C#
body: <p>I am using this piece of code to get the CPU / motherboard serial number:</p>
  <pre><code>macid = AuraRijndael.GetMacID();
  ManagementObjectCollection mbsList = null;
  ManagementObjectSearcher mbs = new ManagementObjectSearcher(&quot;Select * From Win32_processor&quot;);
  mbsList = mbs.Get();
  foreach (ManagementObject mo in mbsList)
  {
      id = mo[&quot;ProcessorID&quot;].ToString();
  }
  
  ManagementObjectSearcher mos = new ManagementObjectSearcher(&quot;SELECT * FROM Win32_BaseBoard&quot;);
  ManagementObjectCollection moc = mos.Get();
  foreach (ManagementObject mo in moc)
  {
      motherBoard = (string)mo[&quot;SerialNumber&quot;];
  }
  </code></pre>
  <p>But it doesn’t work on some machines. On a <a href="https://en.wikipedia.org/wiki/Lenovo" rel="nofollow noreferrer">Lenovo</a> it works fine, but on others it doesn't. Is there a foolproof way of getting the CPU / motherboard serial number?</p>
  <p>Are there machine specific unique id generation mechanisms possible that is also reliable? (I would appreciate any examples.)</p>