19

Im looking for a unique GUID stored in the Windows registry that would help me identify a Windows installation or PC.

The GUID must;

  • Always exist
  • Be unique to a particular Windows installation, i.e. no other computer would have the same ID
  • Never change

Many thanks

1

12 Answers 12

11

You can get GUID from windows registry, for example:

var regpath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\MachineGuid";
var oWSS = new ActiveXObject("WScript.Shell");
clientGUID = oWSS.RegRead(regpath);
5
  • is your code in C# or some other programming language?
    – Tim
    Mar 29, 2017 at 21:52
  • It's JavaScript I've used in windows 7 gadget.
    – friednail
    Mar 30, 2017 at 9:14
  • 1
    Do C# and Javascript have very similar syntaxes?
    – Tim
    Mar 30, 2017 at 14:10
  • Sorry, can't tell you, I'm not familiar with C#. These are just a 3 lines of a simple code, they contain variable definition, string literal, creation of new object and using a dot notation to access an object's method. Probably there are tons of another code structures to compare languages by.
    – friednail
    Mar 31, 2017 at 8:41
  • @Tim, I guess you are interested in reading registry keys in C#? If so, maybe this SO question will be helpful for you
    – friednail
    Mar 31, 2017 at 8:45
7

Do you expect this number to change or stay the same if the drive for that install is moved to another system?

Do you expect this number to be changed if the install is cloned with ghost or something else? Can you depend on cloned systems always being sysprep'd following Microsoft's recommendations? The SID should be fine, if you can be sure your installs are never cloned.

In the case of a multi-boot system (i.e. system has Windows 7 and a Windows XP install) do you need to identify the two installs as unique, or related or what?

Why do you need this to be part of the windows installation, and not something presented by the hardware, perhaps the processor serial number?

I am assuming you are asking about this for some kind of script or tool you are using for inventory purposes?

Why don't you simply generate your own number the first time you run the tool and save it in the LOCAL_MACHINE registry hive? Perhaps even use an RFC4122 Type 1 number and which should include the hardware address for one of the network interfaces. That way you can check to see if the UUID still belongs to that system by comparing the UUID against the present network adapters.

3

You want to use the Windows Product ID. This is a unique number generated (hashed) partially from the product key installed, and partially from the hardware configuration, including processor serial number and MAC address from the first NIC. You can read about it on this (somewhat dated, but still valid) TechNet article. The product ID can be found on the System Information screen, or programatically through several methods.

System Information

3
  • 2
    The registry that holds the users window license is located at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion, no special tricks needed to read it May 14, 2018 at 7:38
  • Not unique, I've just came across duplicate Product Id's Jul 26, 2021 at 11:12
  • Changes when Windows is activated. I also suspect it changes on major Windows updates or in some other situations. Aug 9, 2021 at 15:09
0

Assuming it's a Windows server, there's a knowledge base article that talks about how to get it out of Win2k: KB224544.

I don't know if LDP.exe still operates like that, but it may.

2
  • That article only applies to Domain Controllers.
    – MDMarra
    Dec 12, 2009 at 23:40
  • Thank you for the information, im looking for a GUID that would exist on all Windows versions, XP and above
    – user28967
    Dec 12, 2009 at 23:48
0

I'm not so sure a GUID value like the one you describe actually exists. A common practice is to use CPU or motherboard ID info.

Here is a link to a forum post that contains some relevant WMI script code: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic59274.aspx

0

If you're looking to identify a Windows installation, then you may be out of luck. In corporate environments, workstations are often imaged rather that installed. Each computer built from this image will be identical.

The closest thing to what you've described is the machine's SID, however this doesn't work for two reasons:

  1. Imaged Windows XP machines have the same SID unless you run NewSID against them, which many people don't.
  2. All domain controllers on a single domain share the same machine SID.

What do you need this identifier for? Your best bet may be to generate your own, if that is possible.

1
  • 1
    If the machines are syspreps after imaging then the SID will be different. If they aren't (which all to often they aren't) the SIDs will be the same.
    – mrdenny
    Dec 13, 2009 at 21:16
0

You could try the MAC address, which is at least intended to be globally unique and permanent. This would also have the nice advantage that you could obtain a machine's IP and hostname without too much bother (and it wouln't be restricted to Windows either). It wouldn't meet your requirement of being in the registry, but you can use WMI for it instead.

Sample scripts here: http://www.winforums.com/showthread.php?t=8842

0

How about the DriveId of the system volume? You can get the id from the Win32_Volume WMI class, by looking for entries with SystemVolume True.

In PowerShell:

gwmi win32_volume -filter 'SystemVolume=true' | ft -a DriveLetter,SystemVolume,DeviceId

(This can of course be remoted.)

0

There's a SID used by Windows Update which you might be able to use. Again there is no guarantee that it will be unique every time, or that it won't change.

I think that the closest thing to meet your needs would be the MAC address, however that to could change if the NIC were replaced.

Your best bet would be to write your own GUID into the registry and use that.

0

To confirm the machine SID on a particular machine, you can run SysInternals PSGETSID %COMPUTERNAME%$. (Domain SID).

http://blogs.msdn.com/aaron_margosis/archive/2009/11/05/machine-sids-and-domain-sids.aspx

EDIT: Removed references to machine SID in registry, which may not be unique (or even correct).

7
-1

Why not just use the computer name? Its going to be unique within your domain, all windows installations have one and will only change if a domain administrator changes it which should never be needed unless making a correction.

-2

I, too need, to find a way to globally uniquely identify Windows installations. Firstly, in order to properly classify and identify backup images and determine which ones get recovered on which machines. Secondly, in order to name sychronization pairs for synchronizing files and to determine which synchronization pair to use depending on the machines involved in the synchronization.

After reading several posts, including those on this website, I conclude that there is no easy way to find a globally unique identifier of a Windows installation. That is too bad. Like the hardware, the software should also have its own serial number. Oh well! So this is my workaround: Instead of finding one single globally unique identifier, I have created a sylized statement, which is inspired on the way in which Microsoft names network drives on Windows and the way it names shared folders in Virtual PC: "[WINDOWS PRODUCT ID (as variable)] Installed on [COMPUTER SERIAL NUMBER (as variable)]." Although a Windows production identification number is unique only insofar as the corresponding product key is, it is, nevertheless, liable to be the same across several installations, especially on mass-produced computers containing factory-installed Windows, but a serial number is unique and is different from one machine to another. The above-mentioned formula is all I need for my purposes; I do not need the SID (I presume that it signifies Security Identifier) or something else more complex, because the combination of both variables references exactly the Windows installation that I need to identify, whereas each individual variable is, on its own, of no use to me. Specifically and firstly, the Windows product identification is identical on computers made by the same manufacturer and found in the same product line and that serves me no purpose, since I own several identical machines. Secondly, the serial number is not uniquely identifying enough, since I do have several Windows installations on one computer that a computer serial number does not address. I therefore suggest my method.

Also, and before you inquire about it: I chose not to base my method on the computer name. The information is user-based and therefore needs to be inventoried. However, the Windows product identification and the computer serial number are already identified, inventoried and invariably connected to two specific products, thereby eliminating the need to inventory them again. I would neither elect to identify a Windows installation with a unique identifier of hard drives, since I am able and quite apt to switch them around from one machine to another, especially when drive capacities are in a state of constant flux. By the same token, I would much less use the identifying nomenclature of either the central processing unit or the motherboard, as has been heretofore suggested in a previous reply by Shoeless. Finally, I also reject the most obvious option of identifying a Windows installation (although it has not been mentionned by anybody else from what I can see): using the product key. Although it is unique, it is only a license to install a certain version of Windows; it is not actually connected to a particular Windows installation and it does not distinguish it as being installed on a particular machine, even though the license was granted by virtue of the purchase a given computer.

1
  • 3
    And your answer to the question is...? Oct 1, 2014 at 5:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .