Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there really any way to uniquely identify any computer at all
    primarykey
    data
    text
    <p>I know there are a number of similar questions in stackoverflow such as the followings:</p> <ul> <li><a href="https://stackoverflow.com/questions/671876/whats-a-good-way-to-uniquely-identify-a-computer">What's a good way to uniquely identify a computer?</a></li> <li><a href="https://stackoverflow.com/questions/3443093/what-is-a-good-unique-pc-identifier">What is a good unique PC identifier?</a></li> <li><a href="https://stackoverflow.com/questions/3474940/unique-computer-id-c-sharp">Unique computer id C#</a></li> <li><a href="https://stackoverflow.com/questions/1101772/win32-processoris-processorid-unique-for-all-computers">WIN32_Processor::Is ProcessorId Unique for all computers</a></li> <li><a href="https://stackoverflow.com/questions/1417400/how-to-uniquely-identify-computer-using-c">How to uniquely identify computer using C#?</a></li> </ul> <p>... and dozens more and I have studied them all.</p> <p>The problem is that some of the accepted answers have suggested MAC address as an unique identifier which is entirely incorrect. Some other answers have suggested to use a combination of various components which seems more logical. However, in case of using a combination it should be considered which component is naturally unlikely to be changed frequently. A few days ago we developed a key generator for a software licensing issue where we used the combination of CPUID and MAC to identify a windows pc uniquely and till practical testing we thought our approach was good enough. Ironically when we went testing it we found three computers returning the same id with our key generator!</p> <p>So, is there really any way to uniquely identify any computer at all? Right now we just need to make our key generator to work on windows pc. Some way (if possible at all) using c# would be great as our system is developed on .net.</p> <p><strong>Update:</strong></p> <p>Sorry for creating some confusions and an apparently false alarm. We found out some incorrectness in our method of retrieving HW info. Primarily I thought of deleting this question as now my own confusion has gone and I do believe that a combination of two or more components is good enough to identify a computer. However, then I decided to keep it because I think I should clarify what was causing the problem as the same thing might hurt some other guy in future.</p> <p>This is what we were doing (excluding other codes):</p> <p>We were using a <code>getManagementInfo</code> function to retrieve MAC and Processor ID</p> <pre><code>private String getManagementInfo(String StrKey_String, String strIndex) { String strHwInfo = null; try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + StrKey_String); foreach (ManagementObject share in searcher.Get()) { strHwInfo += share[strIndex]; } } catch (Exception ex) { // show some error message } return strHwInfo; } </code></pre> <p>Then where needed we used that function to retrieve MAC Address</p> <pre><code>string strMAC = getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress"); </code></pre> <p>and to retrieve ProcessorID</p> <pre><code>string strProcessorId = getManagementInfo("Win32_Processor", "ProcessorId"); </code></pre> <p>At this point, <code>strMAC</code> would contain more than one MAC address if there are more than one. To take only one we just took the first 17 characters (12 MAC digits and 5 colons in between).</p> <pre><code>strMAC = strMAC.Length &gt; 17 ? strMAC.Remove(17) : strMAC; </code></pre> <p>This is where we made the mistake. Because <code>getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress")</code> was returning a number of extra MAC addresses that were really in use. For example, when we searched for MAC addresses in the command prompt by <code>getmac</code> command then it showed one or two MAC addresses for each pc which were all different. But <code>getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress")</code> returned four to five MAC addresses some of which were identical for all computers. As we just took the first MAC address that our function returned instead of checking anything else, the identical MAC addresses were taken in <code>strMAC</code> incidently. </p> <p>The following code by <a href="http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer" rel="nofollow noreferrer">Sowkot Osman</a> does the trick by returning only the first active/ enabled MAC address:</p> <pre><code>private static string macId() { return identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled"); } private static string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue) { string result = ""; System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); System.Management.ManagementObjectCollection moc = mc.GetInstances(); foreach (System.Management.ManagementObject mo in moc) { if (mo[wmiMustBeTrue].ToString() == "True") { //Only get the first one if (result == "") { try { result = mo[wmiProperty].ToString(); break; } catch { } } } } return result; } //Return a hardware identifier private static string identifier(string wmiClass, string wmiProperty) { string result = ""; System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); System.Management.ManagementObjectCollection moc = mc.GetInstances(); foreach (System.Management.ManagementObject mo in moc) { //Only get the first one if (result == "") { try { result = mo[wmiProperty].ToString(); break; } catch { } } } return result; } </code></pre> <p>However, I was absolutely right about the identical Processor ID issue. All three returned the same Processor ID when we put <code>wmic cpu get ProcessorId</code> command in their command prompts.</p> <p>Now we have decided to use Motherboard serial number instead of Processor ID to make a combination with MAC address. I think our purpose will be served with this way and if it doesn't in some cases then we should let it go in those few cases.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload