Extracting Windows Key - aesser11/home-lab GitHub Wiki

UEFI Embedded Options

Run in a powershell or cmd window

  1. (Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey
  2. wmic path softwarelicensingservice get OA3xOriginalProductKey

Registry Options

save the following as a .vbs script

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

Run this command to to uninstall the key from the system

This is for OEM keys so they can be used elsewhere. If there's an error with the key in the command, try the second one without the key.

  • slmgr /upk <insertkeyhere>
    • slmgr /upk