How to recover your Windows product key

Technical Level : Basic

Summary

If you are planning to reinstall Windows but you can't find your product key, this article will show you where and how you can find your product key.

The key could be:

  • Printed on a Certificate of Authenticity sticker
  • Stored in the Windows Registry
  • Embedded in the PC's UEFI firmware

Note that if you are currently running Windows 10 and wish to reinstall the operating system, you don't need your product key. After the reinstall, Windows 10 will detect that it has been reinstalled on a previously activated system and will automatically reactivate.


Details

Printed on a Certificate of Authenticity Sticker

If your PC came with Windows 7 or earlier, then your product key will be printed on a COA sticker. This sticker verifies that the computer came with a genuine copy of Windows. You will need to examine your computer to find the sticker. On laptops, it's usually on the bottom side. On desktops, it could be on the back, sides, or top. It looks something like this:

Embedded in the PC's UEFI firmware

If you have a newer PC that came with Windows 8 or Windows 10, then your product key likely won't be on a sticker. Instead, computer manufacturers now embed the key right into the computer's UEFI firmware. Unlike the COA sticker, the embedded key can't be smudged off, stolen or erased (easily).

If you want to extract the UEFI key, the process is simple. Open the Start menu, type powershell and then run the program.

Next type the following command in the PowerShell window and hit Enter.

(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

You will be presented with the key in the window.

Stored in the Windows Registry

If your product key isn't embedded in the firmware or you're missing your COA sticker, you're not out of luck as long as you haven't formatted your computer. You can still recover the key because Windows stores it in the registry. Here is how:

1. Open a new Notepad window

2. Copy and paste the following text into the window

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

3. Click File > Save As and save the file to your desktop as productkey.vbs. It's important to include the .vbs extension because this is a Windows Scripting Host file.

4. Close Notepad and double-click the file. Wait a few seconds, and then you will be presented with a popup displaying your product key:

 

Forum Article Info


Last updated December 14, 2019 Views 76,231 Applies to:

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

I tried this and was happy to get a product key however it says Microsoft key invalid!  What gives? 

I tried this and was happy to get a product key however it says Microsoft key invalid!  What gives? 

What was it that said your key was invalid?

Which method above did you use to find your key? The one you extracted may have been a mass upgrade OEM key...

I had licence copy of windows 7,now i installed windows 8.1 pro in pc so how can i find my windows 7 product key,& the product key on microsoft sticker is erased

I followed the instructions but when I dbl clk, it just opens the same notepad file I saved. What is wrong?
In trying to find product key, I used the NOTEPAD method, got a number, but it is different than the one on the label on my pc.  Which one to use to upgrade to Windows 10.

In trying to find product key, I used the NOTEPAD method, got a number, but it is different than the one on the label on my pc.  Which one to use to upgrade to Windows 10.

Hi smrtalec,

What operating system are you currently running? Was this computer upgraded to the current system, or was this OS installed on the computer since you first bought it?

You will probably want to use the key that notepad returned because the key on the sticker is an OEM mass upgrade key. 

In trying to find product key, I used the NOTEPAD method, got a number, but it is different than the one on the label on my pc.  Which one to use to upgrade to Windows 10.

Hi smrtalec,

What operating system are you currently running? Was this computer upgraded to the current system, or was this OS installed on the computer since you first bought it?

You will probably want to use the key that notepad returned because the key on the sticker is an OEM mass upgrade key. 

Thanks for answering so promptly.  The OS is Windows 7, which came installed on the pc when I purchased it in 2014, directly from Dell. I'll follow what you said and use the one that the machine gave me. Again, thanks for the help.
No problem.
I have the exact same problem as everyone else, I got my Dell in 2014 with Windows 7 pro installed, I have not reformatted or modified the drives in any way. I used the Notepad approach to get the product key which did work. At the end of the installation the install indicated that the product key failed to validate and closed. The advice given here doesn't appear to be very accurate.
For "Stored in the Windows Registry" step 3: after clicking "Save As" you must change "Save as type" to "All Files" before entering "productkey.vbs" in the "File name" field.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.