Tuesday, October 4, 2016

How to Find the Windows Product Key

After entering a product key when installing Windows, Microsoft doesn't show it again. We know the product key is stored in the registry at:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId
 
The problem is the product key has to be converted for us to compare it to the original product key on the Windows software package.
This solution will allow you to obtain the product key by creating and executing VB script.
 
1.  Copy and paste the following script into WordPad or NotePad.
(if NotePad removes the hard returns, you may want to use WordPad)
 
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
 
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ConvertToKey = KeyOutput
End Function

 

2. Save the document as plain text with a .vbs extension. (very important!)

3. After saving the .vbs script, double click to run or execute the script.

(The product key will display in a pop-up box.)