I have been trying to find out what is the best way to uniquely identify a computer for licensing purposes.
Here are some suggestions.
Computer SID
In a previous post “Read computer sid on 64-bit machine” I show how to get the Product ID of the operating system as the unique identifier.
Cons
This seemed great and I even used it for a licensing tool until I installed the software on multiple virtual machines!
The VM’s were cloned from the same base image and guess what? They all had the same Product ID, which meant that every computer passed in the same ID.
Network Card Mac address and other hardware items
These do provide a level of uniqueness but there are a few problems:
Cons
- Most computers these days have many network cards, USB wi-fi etc, so which card do you choose to get the MAC address from?
- Unless it’s in a laptop or onboard, NIC’s can easily be replaced.
What is the best unique computer identifier
Thinking logically you want to use an identifier that is likely to change the least so CPU’s, NIC’s, Hard Drives etc etc should all be rejected.
The one component that generally doesn’t change very often is the motherboard. The motherboard has a UUID (Univerally Unique Identifier), that can be read from the bios.
This value is unique in both physical computers and Virtual Machines.
The following code sample is a c# example of how to read the UUID from the motherboard BIOS using the System.Management.ManagementClass to read the Win32_ComputerSystemProduct
[csharp]
using System.Management;
…
…
public static string UUID
{
get
{
string uuid = string.Empty;
ManagementClass mc = new ManagementClass("Win32_ComputerSystemProduct");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
uuid = mo.Properties["UUID"].Value.ToString();
break;
}
return uuid;
}
}
[/csharp]
Note for a full reference of all the Win32 Management classes go here:
MSDN Win32 Classes
Great article!
I am already using UUID of main harddisk but I think motherboard is more lasting than harddisk so I am thinking of switching to motherboard UUID for identification in software licensing.
Could you tell me whether some unbranded motherboards might not have UUID?
Thanks in advance for your assistance.
A quick google gave me an answer.
“Not all vendors supply a UUID”
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/2bd70996-8dbf-4a96-85b0-341b9cf2ad74/
I would still think the motherboard is a pretty safe option. Alternatively you could try the motherboard and have a second object like CPU as a fallback?