Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 11 / How to Extract Your Windows Product (License) Key from a Computer

June 10, 2026

How to Extract Your Windows Product (License) Key from a Computer

In this article, we’ll look at ways to extract the product key used to activate Windows on your device using only the built-in tools, without the need for any third-party programs. A Windows product key is a sequence of 25 characters divided into five groups of five characters each (XXXXX-XXXXX-XXXXX-XXXXX-XXXXX). It is used to activate the operating system and confirm the license is legitimate.

Contents:
  • Retrieving the OEM Windows Product Key From UEFI/BIOS
  • Script to Extract the Windows Product Key from the Registry

  • Older computer and laptop models with preinstalled Windows may have a Certificate of Authenticity (COA) sticker affixed to the device chassis. This sticker contains the vendor OEM information, the Windows edition, and the product key. This was commonly used around ten years ago with older OEM devices that had Windows 7 or 8.1 pre-installed.
  • Around 2012, Microsoft transitioned from physical COA stickers to embedding the Windows product key directly in the system firmware (BIOS/UEFI).

Retrieving the OEM Windows Product Key From UEFI/BIOS

On many OEM laptops with preinstalled Windows, vendors embed the activation key in system firmware, either in BIOS (the product key is stored in a special SLIC table) or in UEFI (as an OEM key in the ACPI MSDM table).

The Windows installer automatically reads this embedded OEM key. Based on the key, Windows Setup automatically determines the appropriate edition, installs, and activates it. In this case, the option to choose a different edition of Windows during installation is not available.

Such an embedded OEM key can be extracted from the UEFI/BIOS firmware using the SoftwareLicensingService WMI class. Open a PowerShell console as an administrator and run the command:

Get-CimInstance SoftwareLicensingService | Select -Expand OA3xOriginalProductKey

This command should display the Windows OEM key stored in the UEFI.

Get-CimInstance - extract OA3xOriginalProductKey from the firmware

If the command returns nothing, this means that the device does not have any keys in its BIOS/UEFI firmware. It is most likely that the OS is activated by a retail key or by using KMS/MAK.

 If you have Linux installed on your device, you can find the Windows key in the ACPI table in UEFI by running this command:

$ sudo strings /sys/firmware/acpi/tables/MSDM | tail -1

Linux - get the Windows product key from ACPI table

Script to Extract the Windows Product Key from the Registry

Even if your BIOS/UEFI contains a product key, the key used to activate Windows may be different. The installed product key is stored encrypted in the Windows registry, in the value of the DigitalProductID parameter under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion. The value is encoded using a simple base-24 algorithm, which makes it easy to decode (it is an obfuscation method rather than real encryption).

DigitalProductID - registry entry stores the encrypted Windows product key (license key)

The VBScript code below extracts the DigitalProductID value from the registry and decodes it, returning the product key used to activate Windows in clear text. Create a text file extract_windows_key.vbs on your desktop. Copy the code below into this file, save it, and then double-click the file to run it.

Set WshShell = CreateObject("WScript.Shell")
regKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
DigitalProductId = WshShell.RegRead(regKey & "DigitalProductId")
WinProductName = "Windows Product Name: " & WshShell.RegRead(regKey & "ProductName") & vbNewLine
WinProductID = "Windows Product ID: " & WshShell.RegRead(regKey & "ProductID") & vbNewLine
WinProductKey = ConvertToKey(DigitalProductId)
strProductKey ="Windows  Key: " & WinProductKey
WinProductID = WinProductName & WinProductID & strProductKey 
MsgBox(WinProductKey)
MsgBox(WinProductID)
Function ConvertToKey(regKey)
Const KeyOffset = 52
isWin8 = (regKey(66) \ 6) And 1
regKey(66) = (regKey(66) And &HF7) Or ((isWin8 And 2) * 4)
j = 24
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
y = 14
Do
Cur = Cur * 256
Cur = regKey(y + KeyOffset) + Cur
regKey(y + KeyOffset) = (Cur \ 24)
Cur = Cur Mod 24
y = y -1
Loop While y >= 0
j = j -1
winKeyOutput = Mid(Chars, Cur + 1, 1) & winKeyOutput
Last = Cur
Loop While j >= 0
If (isWin8 = 1) Then
keypart1 = Mid(winKeyOutput, 2, Last)
insert = "N"
winKeyOutput = Replace(winKeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then winKeyOutput = insert & winKeyOutput
End If
a = Mid(winKeyOutput, 1, 5)
b = Mid(winKeyOutput, 6, 5)
c = Mid(winKeyOutput, 11, 5)
d = Mid(winKeyOutput, 16, 5)
e = Mid(winKeyOutput, 21, 5)
ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e
End Function

The script will return the Windows version and the product key that was used to activate it.

VBS script to extract product key from the registry

In recent Windows 11 builds, the VBScript engine may be disabled, so use this PowerShell function instead of a VBS script to retrieve the Windows product key.

function Get-WindowsProductKey { param ($Targets = [System.Net.Dns]::GetHostName())
function PIDDecoderFromRegistry($digitalProductId) {
$base24 = 'BCDFGHJKMPQRTVWXY2346789'; $decodeStringLength = 24; $decodeLength = 14; $decodedKey = ''
$containsN = ($digitalProductId[$decodeLength] / 8) -band 1
$digitalProductId[$decodeLength] = [byte]($digitalProductId[$decodeLength] -band 0xF7)
for ($i = $decodeStringLength; $i -ge 0; $i--) {
$digitMapIndex = 0
for ($j = $decodeLength; $j -ge 0; $j--) {
$digitMapIndex = $digitMapIndex * 256 -bxor $digitalProductId[$j]
$digitalProductId[$j] = [math]::Truncate($digitMapIndex / $base24.Length)
$digitMapIndex = $digitMapIndex % $base24.Length
}
$decodedKey = $base24[$digitMapIndex] + $decodedKey
}
if ($containsN) {
$firstLetterIndex = $base24.IndexOf($decodedKey[0])
$decodedKey = $decodedKey.Remove(0,1); $decodedKey = $decodedKey.Substring(0,$firstLetterIndex) + 'N' + $decodedKey.Remove(0,$firstLetterIndex)
}
for ($t = 20; $t -ge 5; $t -= 5) { $decodedKey = $decodedKey.Insert($t, '-') }
return $decodedKey
}
$hklm = 2147483650; $regPath = 'Software\Microsoft\Windows NT\CurrentVersion'; $regValue = 'DigitalProductId'
foreach ($target in $Targets) {
$wmi = [WMIClass]"\\$target\root\default:stdRegProv"
$binArray = $wmi.GetBinaryValue($hklm,$regPath,$regValue).uValue[52..66]
$win32os = Get-CimInstance -Class 'Win32_OperatingSystem'
$product = [PSCustomObject]@{
Computer = $target
Caption = $win32os.Caption
CSDVersion = $win32os.CSDVersion
OSArch = $win32os.OSArchitecture
BuildNumber = $win32os.BuildNumber
RegisteredTo = $win32os.RegisteredUser
ProductID = $win32os.SerialNumber
ProductKey = PIDDecoderFromRegistry $binArray
}
Write-Output $product
}
}

Copy the following code into a PowerShell console (or save it in a PowerShell script file with a .PS1 extension), and then run the WindowsProductKey command to call the function. The function will return information about the version of Windows and the activation key used.

Get-WindowsProductKey using PowerShell

In my case, the public GVLK key W269N-WFGWX-YVC9B-4J6C9-T83GX was installed on my Windows 11 Pro device, meaning that this Windows instance was activated on a KMS server.

public GVLK keys for Windows 11 and 10

Both scripts for extracting the product key from the Windows registry are compatible with all versions from Windows XP through Windows 11.

If your product key is displayed as BBBBB-BBBBB-BBBBB-BBBBB-BBBBB, it means that Windows was activated using a Multiple Activation Key (MAK). Due to security concerns, this MAK key is not stored in the registry. Or such a key indicates that the OS was upgraded using the free upgrade procedure from a previous version (for example, from Windows 8.1 to Windows 10). And then a digital license was issued for the device.

Windows 11 activated with a digital license

To extract a product key from an offline system (for example, a failed computer with an intact Windows drive), you can use the free ProduKey tool from NirSoft. The tool allows you to manually specify the Windows directory to scan for the product key or load the product keys from an external Software registry file (for example, from a registry backup).

Product Key Scanner from NirSoft

0 comment
0
Facebook Twitter Google + Pinterest
PowerShellQuestions and AnswersWindows 10Windows 11
previous post
Access a Shared Folder on Windows with a Different Username

Related Reading

How to Move (Migrate) Windows Shares to a...

February 26, 2026

How to Detect Which User Installed or Removed...

June 25, 2025

Security Warnings When Opening RDP Files in Windows...

April 20, 2026

Find a Process Causing High Disk Usage on...

July 16, 2025

Monitor Windows Log Files in Real Time with...

March 26, 2026

SMB over QUIC: Mount File Share over Internet...

December 24, 2025

Automate Software and Settings Deployment with WinGet Configure...

November 20, 2025

Windows Stucks at ‘Getting Windows Ready, Don’t Turn...

September 24, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • How to Monitor Windows Machines with Zabbix

    May 26, 2026
  • Fixing Duplicate Security Identifier (SID) Issues in Windows

    May 25, 2026
  • Monitor a Folder for File Changes Using PowerShell and FileSystemWatcher

    May 15, 2026
  • Protect Windows Server from DDoS and Brute-Force Attacks with IPBan

    May 12, 2026
  • How to Force Uninstall ANY Stubborn Program in Windows

    May 7, 2026
  • How to Safely Disable IPv6 on Windows

    April 30, 2026
  • Updating UEFI Secure Boot Certificates on Windows Devices Explained

    April 20, 2026
  • Security Warnings When Opening RDP Files in Windows 11

    April 17, 2026
  • Find Computers with Pending Reboot Status Using PowerShell

    April 15, 2026
  • Mounting NFS Shares in Windows Using the Built-in Client

    March 26, 2026

Follow us

  • Facebook
  • Twitter
  • Youtube
  • Telegram
Popular Posts
  • Run Elevated Commands with Sudo on Windows 11
  • Fix: Slow Startup of PowerShell Console and Scripts
  • Automate Software and Settings Deployment with WinGet Configure (DSC)
  • How to Hide (Block) a Specific Windows Update
  • Pin and Unpin Apps to Taskbar in Windows 11 via PowerShell
  • Enable/Disable Random Hardware (MAC) Address for Wi-Fi on Windows
  • How to Pause (Delay) Update Installation on Windows 11 and 10
Footer Logo

@2014 - 2026 - Windows OS Hub. All about operating systems for sysadmins


Back To Top