WARNING! The following entry contains registry related code. Incorrectly modifying the registry could render your system unusable, requiring reinstallation. If you are unsure as to what the following code is doing or are not comfortable working with the registry, navigate away from the page and visit the MSDN Registry Reference first.

USE THIS CODE ONLY AT YOUR OWN RISK! RISK!!

Retrieve XP Product Key

This program queries the registry for the product key used to install Windows XP on the current machine and displays it onscreen.


In previous versions of Windows, the key used at installation time was stored in string form within the registry and was easily viewable using RegEdit. Currently, that 25 character key is encoded in a 15 byte chunk of a 164 byte (I believe) registry entry called DigitalProductID. Having once found myself in a position of needing to get a 20 user office fully license-compliant in a very short amount of time, I failed to record which key was used on which machine. When one workstation eventually suffered a complete hard disk failure, I was left not knowing which of those 20 keys I could use to install XP to a new hard disk on that workstation. Some online searching led to an algorithm in VBScript to decode the installation key from the DigitalProductID entry (contained within the DecodeKey sub below). This is a simplified version of the resulting program I wrote to extract the key from every machine in our office network. This version displays only the local machine's product key in a notice window. It has been used on Windows XP Pro SP2 and Server 2003 Enterprise SP1.