sodcalculator

10 Tech How-To

Windows 10 Product Key via VBScript: How to Find It

Guide 10-24010 · Updated · Step by step

This guide shows you how to retrieve your Windows 10 product key using a small VBScript, and explains what the result actually means. You’ll need a working Windows 10 PC and permission to create a text file—no extra software or admin rights are required for the basic method.

What You’ll Need

  • A Windows 10 computer (any edition, Home, Pro, etc.)
  • Notepad (built into Windows) or any plain text editor
  • Basic ability to create and save a file with a .vbs extension

Step-by-Step

  1. Open Notepad. Press Win + R, type notepad, and press Enter. Or search for “Notepad” from the Start menu.
  2. Copy the VBScript code below. Select and copy the following exactly:
    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. Paste the code into Notepad. Click in the Notepad window and press Ctrl + V to paste.
  4. Save the file with a .vbs extension. Click File > Save As. In the “Save as type” dropdown, choose “All Files (*.*)”. In the “File name” field, type something like getkey.vbs (the .vbs extension is critical). Choose a location you can find, like your Desktop, and click Save.
  5. Run the script. Navigate to where you saved the file and double-click it. A pop-up message box will appear showing your Windows 10 product key in the format XXXXX-XXXXX-XXXXX-XXXXX-XXXXX.
  6. Write down the key. The message box only shows the key; it doesn’t copy it to your clipboard automatically. Note it down or take a photo. To copy it manually, you can press Ctrl + C after selecting the text in the message box (if your system allows it), but often you’ll need to retype it.

Common Mistakes

  • Wrong file extension: Saving as getkey.vbs.txt will make it open in Notepad instead of running. Always select “All Files” and ensure the name ends with .vbs.
  • Copying errors: A single wrong character in the script will cause a syntax error. Copy the code exactly, including all parentheses and quotes.
  • Running as administrator unnecessarily: This script reads from the registry and works without admin rights. If you right-click and “Run as administrator” and get a UAC prompt, that’s fine, but it’s not required.
  • Confusing the key with the Windows edition: The script returns the product key, not the edition (e.g., Home or Pro). The edition is visible in Settings > System > About.

Tips

  • Backup the key: Once you have the key, store it in a safe place, like a password manager or a physical note. It’s needed for reinstalls or support.
  • Use for OEM or Retail: The script works for both OEM (preinstalled) and retail keys. For digital licenses linked to your Microsoft account, the key may still be present in the registry.
  • If the key shows as “BBBBB-BBBBB…” That means the registry value is a placeholder, often for digital licenses. Your actual key may be stored in your Microsoft account, not the local registry.
  • Run from a USB or external drive: You can put the .vbs file on a USB stick and run it on any Windows 10 PC, which is handy for recovering keys from multiple machines.

Troubleshooting

  • “Windows Script Host” error: If you see “Cannot find script file” or a syntax error, double-check the file extension and the code. Re-copy the code from this page and save again.
  • No message box appears: If nothing happens when you double-click, the file may have been saved as .txt. Check the file’s properties—if the type is “Text Document,” rename it to .vbs (you may need to enable “File name extensions” in File Explorer).
  • Key shows as all zeros or invalid: This can happen if the registry value is corrupted or if the system uses a digital license. Try the script on a different Windows 10 machine to confirm it works. If it still fails, your key might not be stored locally.
  • “Access denied” when running: This is rare, but if it occurs, try running the script as administrator. Right-click the file and choose “Run as administrator.”
  • Script is blocked by security software: Some antivirus programs may flag .vbs files as potentially unsafe. If so, temporarily disable the real-time protection, run the script, then re-enable it. Never disable security software for untrusted scripts.

Frequently Asked Questions

Is this method legal?

Yes, you are reading your own product key from your own computer’s registry. It’s a standard technique used by IT professionals for legitimate recovery.

Will this work on Windows 11?

The script reads the same registry location, so it generally works on Windows 11 as well. This guide focuses on Windows 10, but the method is compatible.

I get a key, but it’s different from the one on my sticker. Why?

OEM computers often have a generic key in the registry, while the actual unique key is on the sticker or embedded in the firmware. The script reads the registry, which may not match the sticker. For the firmware key, use a tool like wmic path softwarelicensingservice get OA3xOriginalProductKey in Command Prompt.

Can I use this key to reinstall Windows?

Yes, if it’s a valid key. However, if your PC uses a digital license, you may not need to enter the key during reinstall—Windows will automatically activate based on your hardware.

Why does the script show a key with letters only, no numbers?

The script uses a character set that excludes digits 0 and 1 to avoid confusion with letters O and I. That’s normal—your actual key also uses this set.

What if I lost my key and this script doesn’t work?

If the registry key is missing, you can try looking for the key on a sticker on your PC, or in your Microsoft account if you linked the digital license. For enterprise or volume license keys, contact your IT department.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →