I had to reinstall Windows 7 on an old desktop PC, where the Product Key
printed on the COA sticker was unreadable. Before reinstalling,
with a simple script, I recovered the Windows 7 product key stored in the
Windows registry, without third-party tool.
The VBA script that I report has been modified by me; it also report the edition
of Windows 7 associated with the product key. Remember that you can use the
same product key to activate 32 or 64 bit as long as they are of the same
edition. Successfully tested on Windows 7 Pro x64 with SP1.
Step 1: Open Windows 7 Notepad
You can do this by clicking on the Start menu and typing Notepad in the search bar.
Step 2: Build the script
and paste the following code into Notepad.
Set WshShell = CreateObject("WScript.Shell")
' read the OS in the registry
OS_Version = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
' read the key in the registry
ProductKey = ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
MsgBox OS_Version & VbCrlf & ProductKey
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
Step 3: Save the script
Click File and then Save As. Choose a location to save the file, for example on the Desktop, and give it a name like RecoverWindows7Key.vbs. Make sure you select All Files as the file type in the Save As dialog box, then click Save. Note: It's important to include the .vbs extension in the filename because this is a Windows Scripting Host file.
Step 4: Run the script
Close Notepad and double-click the file you just created. Wait a few seconds and a popup will show your Windows 7 edition and product key. You can copy the message to the clipboard by pressing Ctrl + C while the popup window is active. Paste it into Notepad and save it in a safe place for future reference.
Was this guide helpful? Let me know in the comments below, and don't forget to share it with anyone facing the same issue!
Comments
Post a Comment