How do I obtain the serial number of the CPU in a PC?
This is and old thread. But I had a same problem, but I got the following logic working without too many ifs, ands or buts.
The problem with CPU serial number is that it does not always work in virtualized environment.
I did the following logic with a set of Windows-based servers:
Win32_BIOS can provide you a serial number of the bios. We need to keep in mind that if the system is virtualized, you could end up with same bios serial number for all servers.
Win32_NetworkAdapter can provide you a MAC that you can use as well. In cases where you have multiple NICs, you will end up with multiple-MACs.
Combining both these IDs, I had all unique set over a set of 6000 servers spanning across physical and virtual. This was really simple to implement using ManagementClass & ManagementObject.
But just a caveat: when you try to get the MO instance remotely, it'll take more than a few seconds on a <5ms latency 10Gbps optical network. So if you do the math it took me over 3 hours on a single thread operation. Since this is more like a low-priority traffic I didn't want to spam my network for gathering WMI data on multi-threaded call.