What is a good unique PC identifier?

0 votes
asked Aug 9, 2010 by dlras2

I've been looking at the code in this tutorial, and I found that it uses My.Computer.Name to save settings that shouldn't roam between computers. It's entirely possible, however, for a user to have two identically named PCs. If they wanted to have the same username on each PC, for example, they may very well end up with two PCs named Username-PC.

What are some good methods of identifying different PCs? Do PCs have GUIDs associated with them, or should I look into pulling the serial number off of some hardware? I don't care if the identification persists through reinstallation of Windows.

(The tutorial I linked is in VB.Net, but I'm implementing it in C#)

10 Answers

0 votes
answered Jan 9, 2010 by user279521

I don't think it's possible to have two PC's with the same name on the same domain. Have you tried capturing the domain name?

0 votes
answered Jan 9, 2010 by jonh

Take a look here: Getting Service Tag from Dell Machine using .net?

You could snatch some unique data from the registry.

0 votes
answered Aug 9, 2010 by mattbasta

Some good identifiers:

  • MAC Address: It's fairly easy to get at, and it's usually unique. However, it can be spoofed/changed rather easily, so it depends on how unique it needs to be.
  • CPU Serial Number: It's not available on lots of older systems, but it's there. Check out this MSDN page. It won't change, but it's bound to a computer.
  • HDD Serial Number: It's likely to not change, but can be a nuisance if the HD fails. Check out this MSDN page.
0 votes
answered Aug 9, 2010 by schoetbi

One thing you can use is the MAC of any Network interface. You can also combine several sources of information. Like HDD Serial number, mac, processor type to calculate a hash from it.

0 votes
answered Aug 9, 2010 by steven-sudit

Each computer has a SID that's unique under normal circumstances.

0 votes
answered Aug 9, 2010 by scott-chamberlain

If you are on windows HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\ProductId is unique per machine/per windows install. where as in some of the other answers like the MAC address, Proc SN, and HD SN will stay the same between windows reinstalls/dual boot situations.

0 votes
answered Aug 9, 2010 by micsim

Use the network card's MAC address. It's supposed to be unique. It can be changed, though. It depends on how malicious you expect your users to be and how critical your application is.

Some sample code to do it:

public string GetMACAddress() {
    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
    ManagementObjectCollection moc = mc.GetInstances();

    string MACAddress = String.Empty;

    foreach (ManagementObject mo in moc) {
        if (MACAddress == String.Empty) { // only return MAC Address from first card
            if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();

    return MACAddress;
0 votes
answered Aug 22, 2012 by digmi

The real answer to that question: There is no such thing.

There are several "close enough" solutions, but each one of those has it's own limitation.

All the hardware IDs - Hardware changes. And, in many cases you can change those identifiers (For example, MAC spoofing).

The SID, as I've already commented, Is not that good as well, because the SID won't change if the computer was installed from an image. The SID is generated by windows installation, if windows wasn't installed, but copied from an image, the SID won't change (although it is common to regenerate it because of a myth about "security risk" - you can't count on that).

Computer name - Well, as mentioned, They suppose to be unique, but it's not enforced in any way.

Another solution you can implement is to generate you own unique identifier and store it locally (assuming you can do such thing). Again, this solution won't work if your computer was imaged with your application.

The best solution for you really depends on what you are trying to accomplish. I had the same problem with a quite large network, and the best solution in my case was the computer's name. If you are absolutely sure that your process won't be imaged, I would generate a unique identifier using Guid because it will probably be the safest.

0 votes
answered Aug 5, 2013 by andrewmcc

Here is a way to uniquely identify a computer. Using System.Management to get Win32_BIOS, you can get unique values from your machine's BIOS.

See: Win32_BIOS class, http://msdn.microsoft.com/en-us/library/aa394077.aspx

using System.Management;

string UniqueMachineId()
    StringBuilder builder = new StringBuilder();

    String query = "SELECT * FROM Win32_BIOS";
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
    //  This should only find one
    foreach (ManagementObject item in searcher.Get())
        Object obj = item["Manufacturer"];
        obj = item["SerialNumber"];

return builder.ToString();

With similar logic, you can also step through "Win32_DiskDrive"; http://msdn.microsoft.com/en-us/library/aa394132.aspx; and get "SerialNumber" for each physical drive. In this case, the

    foreach (ManagementObject item in searcher.Get())

should find multiple items

0 votes
answered Sep 15, 2017 by tomminn

Take three identifiers that are semi-unique and semi-constant. Use the rule that 2 out of 3 is sufficient for a positive identification. Update the registered data for the 1 out of 3 that is occasionally wrong.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter