If you’ve ever needed to reinstall Windows or move your license to a new PC, you’ll know that finding your Windows product key can sometimes be a bit of a challenge. Fortunately, there’s a simple and effective way to retrieve your Windows product key using a VBS (Visual Basic Script) file. In this post, I’ll guide you through the process of creating a script using Notepad that will reveal your Windows product key in just a few steps.
What You Need
- A Windows PC
- Notepad (which comes pre-installed on all versions of Windows)
Step-by-Step Guide to Retrieve Your Windows Product Key
Step 1: Open Notepad
The first step is to open Notepad. You can do this by:
- Pressing
Windows + R
on your keyboard to open the Run dialog box. - Typing
notepad
and pressing Enter.
Step 2: Copy and Paste the VBS Script
Next, you’ll need to copy a small script into Notepad. This script will extract the product key from your Windows registry.
Here’s the script you need:
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 FunctionSimply copy this entire block of code and paste it into your open Notepad window.
Step 3: Save the File as a VBS Script
After pasting the script into Notepad, you’ll need to save it as a VBS file:
- Click on
File
in the top menu and selectSave As...
.- In the “Save as type” dropdown, choose
All Files
.- Name your file something memorable, such as
GetWindowsKey.vbs
.- Make sure to add
.vbs
at the end of the file name so that it saves as a VBS script.- Choose a location to save the file (your Desktop is a good choice), and click
Save
.Step 4: Run the VBS Script
Now that you’ve saved your script, it’s time to run it:
- Navigate to where you saved the file (e.g., your Desktop).
- Double-click the
GetWindowsKey.vbs
file.A message box should appear displaying your Windows product key. You can write this key down or save it somewhere safe for future use.
Additional Tips
- Compatibility: This method works on most versions of Windows, including Windows 7, 8, 10, and 11.
- Administrative Rights: In some cases, you may need to run the script with administrative privileges. If the script doesn’t work as expected, try right-clicking the
.vbs
file and selectingRun as administrator
.- Backup: Always make sure to keep a backup of your product key in a secure place. This key is crucial for reinstalling or activating Windows.
Conclusion
Using this simple Notepad and VBS script method, you can easily retrieve your Windows product key in just a few steps. This can save you time and effort when you need to reinstall Windows or move your license to a new computer. Happy scripting!