Into Windows

  • Home
  • Windows 11
  • Windows 10
  • Windows 7
  • Privacy
You are here: Home » Windows 10 » How To Recover Windows 10/8/7 Product Key Without Using Third-Party Tools

How To Recover Windows 10/8/7 Product Key Without Using Third-Party Tools

Last Updated on April 5, 2020 by admin 12 Comments

There are times when you may want to recover your Windows product key from a working Windows installation, whether to back up the product key before beginning to install a newer version of Windows, or to reinstall existing version of Windows operating system.

The standard or the popular way of retrieving Windows product key is to use a third-party software such as License Crawler or use a free Windows product key recovery CD to recover the product key from unbootable PCs.

Recover Windows Prodcut Key Without tools1

While there are plenty of free tools available for this job, the fact is that one can recover Windows product key from registry without having to use third-party tools.

Out friend at WinAero has posted a helpful guide on recovering Windows product key without using third-party tools. The only thing is that your PC must be bootable to recover the product key using this method. And if your PC is unbootable, follow our how to recover Windows 7/8/8/8.1 product key from unbootable PC guide.

NOTE: This method works in all recent versions of Windows, including Windows 7, Windows 8, and Windows 8.1.

Step 1: Copy the following code and paste it into Notepad. Save the file as RecoverKey.ps1 on your desktop. Note that it’s important to save the file with .ps1 extension.

function Get-WindowsKey {
## function to retrieve the Windows Product Key from any PC
## by Jakob Bindslet (jakob@bindslet.dk)
param ($targets = “.”)
$hklm = 2147483650
$regPath = “Software\Microsoft\Windows NT\CurrentVersion”
$regValue = “DigitalProductId”
Foreach ($target in $targets) {
$productKey = $null
$win32os = $null
$wmi = [WMIClass]”\\$target\root\default:stdRegProv”
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue)
$binArray = ($data.uValue)[52..66]
$charsArray = “B”,”C”,”D”,”F”,”G”,”H”,”J”,”K”,”M”,”P”,”Q”,”R”,”T”,”V”,”W”,”X”,”Y”,”2″,”3″,”4″,”6″,”7″,”8″,”9″
## decrypt base24 encoded binary data
For ($i = 24; $i -ge 0; $i–) {
$k = 0
For ($j = 14; $j -ge 0; $j–) {
$k = $k * 256 -bxor $binArray[$j]
$binArray[$j] = [math]::truncate($k / 24)
$k = $k % 24
}
$productKey = $charsArray[$k] + $productKey
If (($i % 5 -eq 0) -and ($i -ne 0)) {
$productKey = “-” + $productKey
}
}
$win32os = Get-WmiObject Win32_OperatingSystem -computer $target
$obj = New-Object Object
$obj | Add-Member Noteproperty Computer -value $target
$obj | Add-Member Noteproperty Caption -value $win32os.Caption
$obj | Add-Member Noteproperty CSDVersion -value $win32os.CSDVersion
$obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
$obj | Add-Member Noteproperty BuildNumber -value $win32os.BuildNumber
$obj | Add-Member Noteproperty RegisteredTo -value $win32os.RegisteredUser
$obj | Add-Member Noteproperty ProductID -value $win32os.SerialNumber
$obj | Add-Member Noteproperty ProductKey -value $productkey
$obj
}
}

Recover Windows Product Key Without Using Third Party Tools Step1

Recover Windows Product Key Without Using Third Party Tools Step2

Step 2: Open Windows PowerShell as administrator. To do this, you can type Windows PowerShell in the Start menu (Windows 7) or Start screen (Windows 8/8.1), and then simultaneously press Ctrl + Shift + Enter keys.

Recover Windows Product Key Without Using Third Party Tools Step33

Alternatively, you can right-click on the Windows 8.1 Start button and then click Windows PowerShell (Admin) to launch PowerShell as administrator.

Recover Windows Product Key Without Using Third Party Tools Step34

Click on the Yes button when you see the User Account Control (UAC) dialog.

Step 3: In the PowerShell window, type the following code (or you can simply copy and paste) and press Enter key to change the execution policy for non-signed scripts.

Set-ExecutionPolicy RemoteSigned

Recover Windows Product Key Without Using Third Party Tools Step3

Click Enter key or ‘Y’ key when you see “Do you want to change the execution policy” message.

Recover Windows Product Key Without Using Third Party Tools Step4

Step 4: Finally, type the following command and then press Enter key to view your Windows product key. That’s it!

Import-Module C:\Users\PC\Desktop\RecoverKey.ps1; Get-WindowsKey

In the above command, replace “C:\Users\PC\Desktop\RecoverKey.ps1” with the path to the previously saved RecoverKey.ps1 file. To easily get the path, press and hold down the Shift key, right-click on RecoverKey.ps1 file, and then click Copy as path option.

Recover Windows Prodcut Key Without tools

Recover Windows Product Key Without Using Third Party Tools Step6

Good luck!

Filed Under: Windows 10 Tagged: Tips

Related Posts

  • How To Recover Windows 7 Product Key
  • How To Recover Windows 8 Product Key
  • How To Recover Windows Product Key From Windows.old Folder
  • Windows 10 Preview Product Key
  • How To Recover Windows 8/8.1 Product Key From BIOS
  • How To Recover Office 2010 Product Key

Comments

  1. WakeUp says

    August 5, 2023 at 6:22 am

    Copy and paste a script from the web? Not very useful on a virus-ridden machine that you want to keep offline, though, is it?

  2. Zac says

    July 28, 2020 at 8:41 pm

    Hey there! I’m trying to do this on Windows 7 and I’m getting errors. I think I’ve fixed all the odd commas and hyphens but I’m still getting the error “You must provide a value expression on the right-hand side of the ‘-‘ operator”, referring to line 16, character 28.

    It also says “the term ‘Get-WindowsKey’ is not recognized as the name of a cmdlet…”

    Any ideas about this? Thanks.

  3. Justn says

    June 15, 2020 at 12:59 am

    Hey Pete! Glad I read the comments first and saved myself a headache!

    The code gave me the Product key right away!

  4. Andre Noun says

    November 7, 2017 at 1:50 pm

    Default is No. Can I change it to Yes? I have tried, but no way.

  5. Juan says

    August 2, 2014 at 8:33 pm

    Thanks Pete, the copy-paste issue is so common with code that it be a worthwhile project to make a script to clean it up.
    Basic concept:
    All types of double quotes — > standard double quote
    Hyphen —> minus – minus

    The screen capture of the code also helps.

  6. Moto says

    June 10, 2014 at 9:33 pm

    Just wanted to drop a note here…after adjusting the script as noted here in the comments, I did get it to run. However…the install code it provided did not work. The Windows 8.1 retail disk that had been used to do the install in the first place would not accept it. (I’m trying to help a friend reinstall…they had BBY install 8.1 for them at one point with a full retail copy he bought there, and I have no idea what they did with the COA)

    So, I went back into Windows and downloaded ProduKey. Which ran fine, and gave a *completely* different install code. I mean, it wasn’t even close. And the Windows 8.1 install CD accepted that code just fine.

    …so I have no idea what to tell you, but somehow the code that this script generated was completely bogus.

  7. Miguel says

    January 8, 2014 at 6:25 am

    please just place a link to download the text document

  8. BKize says

    October 9, 2013 at 4:45 am

    Please ignore my previous post. My apologies.

    There is obviously some text processing on this site that occurs during a post and reformats various characters such as quotes and hyphens. The result is incorrect formatting of the script that has to be corrected manually as Peter describes.

  9. BKize says

    October 9, 2013 at 4:41 am

    Here is a corrected version of the script above that works:

    function Get-WindowsKey {
    ## function to retrieve the Windows Product Key from any PC
    ## by Jakob Bindslet (jakob@bindslet.dk)

    param ($targets = “.”)
    $hklm = 2147483650
    $regPath = “Software\Microsoft\Windows NT\CurrentVersion”
    $regValue = “DigitalProductId”

    Foreach ($target in $targets) {
    $productKey = $null
    $win32os = $null
    $wmi = [WMIClass]”\\$target\root\default:stdRegProv”
    $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue)
    $binArray = ($data.uValue)[52..66]
    $charsArray = “B”,”C”,”D”,”F”,”G”,”H”,”J”,”K”,”M”,”P”,”Q”,”R”,”T”,”V”,”W”,”X”,”Y”,”2″,”3″,”4″,”6″,”7″,”8″,”9″

    ## decrypt base24 encoded binary data
    For ($i = 24; $i -ge 0; $i–) {
    $k = 0
    For ($j = 14; $j -ge 0; $j–) {
    $k = $k * 256 -bxor $binArray[$j]
    $binArray[$j] = [math]::truncate($k / 24)
    $k = $k % 24
    }
    $productKey = $charsArray[$k] + $productKey
    If (($i % 5 -eq 0) -and ($i -ne 0)) {
    $productKey = “-” + $productKey
    }
    }

    $win32os = Get-WmiObject Win32_OperatingSystem -computer $target
    $obj = New-Object Object
    $obj | Add-Member Noteproperty Computer -value $target
    $obj | Add-Member Noteproperty Caption -value $win32os.Caption
    $obj | Add-Member Noteproperty CSDVersion -value $win32os.CSDVersion
    $obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
    $obj | Add-Member Noteproperty BuildNumber -value $win32os.BuildNumber
    $obj | Add-Member Noteproperty RegisteredTo -value $win32os.RegisteredUser
    $obj | Add-Member Noteproperty ProductID -value $win32os.SerialNumber
    $obj | Add-Member Noteproperty ProductKey -value $productkey
    $obj
    }
    }

  10. admin says

    September 26, 2013 at 10:27 pm

    Peter and Robert,
    Thanks for your inputs. The script worked fine on my Windows 8 and 8.1 machines. Will try to fix the quotes issue. Between, we have already reviewed Windows 8 Product Key Viewer here:
    intowindows.com/windows-8-product-key-viewer/

  11. Robert says

    September 26, 2013 at 7:20 pm

    The script fails on my system. Actually asis it won’t run in your copy for some reason (probably due to the “). Anyways I found it elsewhere and on my system it actually failed to retrieve the key. I even set the script to unrestricted. I also tried another script and that version gave me a different and also invalid key. The jellybean key viewer also failed by giving back the wrong key. The only program that worked was the one here… (although it is 3rd party which is not what this article is about)

    forums.mydigitallife.info/threads/30363-Windows-8-Product-Key-Viewer

  12. Peter says

    September 26, 2013 at 7:06 pm

    Couple of gotchas when copying and pasting the code into notepad…

    1. All the quotes will come in as smart quotes instead of plain text quotes. These need to be changed back to standard quote marks for the script to work.

    2. The two “for” loops (lines 16 and 18) have had the “–” (two hyphen characters) changed to “—” (em-dash character) just before the closing bracket on each line. These need to be reverted to two hyphens (as per the notepad screenshot above)

    Aside from that, I can confirm that the script returned my product key correctly.

    Pete.

Leave a Reply

Your email address will not be published. Required fields are marked *

Advertisements

Search Into Windows

Recent posts

  • 5 Ways To Go To Desktop In Windows 11
  • How To Show Battery Percentage On Taskbar In Windows 11
  • Fix: AMD Software Adrenalin Edition Not Opening In Windows 11
  • How To Show Year On Windows 11 Taskbar
  • Windows 11 24H2 Is Available Now
  • How To Create 7z & TAR Files In Windows 11 Without Using Additional Apps
  • How To Remove Bell Icon From Taskbar In Windows 11
  • How To Reinstall Windows 11 Without Losing Apps And Files
  • How To Hide/Show Files & Icons On Desktop In Windows 10/11
  • How To Show Hidden Icons On Taskbar In Windows 11

About us

  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2025 · Into Windows