How to Find the Windows 10 Product Key After an Upgrade

At the recent Microsoft Cloud Roadshow here in Toronto, team CANITPRO was provided the opportunity to present best practices surrounding Windows 10 security, manageability and deployment.

During the session entitled Taking Advantage of the New Deployment Features in Windows 10 the following question was asked:

"How do you find the Windows 10 product key once the upgrade from Windows 7, 8 or 8.1 is completed."

Now traditionally, all that is required to retrieve this information is using the inventory capability via the Mobile Device Management software of choice.  Another option has been made available via third party applications. Be careful when pursuing this route as reports have come forward that some third party applications install adware/malware during the installation of the tool.   In either case, what has been discovered in some cases using both methods is the key provided is actually a generic key akin to one of the following:

  • Windows 10 Enterprise: NPPR9-FWDCX-D2C8J-H872K-2YT43
  • Windows 10 Pro: VK7JG-NPHTM-C97JM-9MPGT-3V66T
  • Windows 10 Home: TX9XD-98N7V-6WMQ6-BX7FG-H8Q99

The trouble with using these keys, should you need to re-enter said key in future, is that it enrolls said Windows 10 installation into Insider Preview. While ok in a lab environment, Insider Preview could be troublesome in a production environment.

Enter Chris Goulard, IT Analyst and member of the #CANITPRO community on Twitter, with a solution via script to provide the actual Windows 10 key provide after upgrade. The script is as follows: 

Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))

Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Cur = 0
x = 14
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

Simply copy and paste the above script into a new notepad file. Name the notepad file what you wish, however change the extension from .txt to .vbs.  Save and run the newly created Key Catcher on a toolset USB key or right on the newly upgraded machine itself and the true key will be provided.

Thank you Chris for the share.

Comments (8)

  1. YLTO says:

    A simple copy and paste on my Windows 10 stripped out a lot of the actual text, including the " and the < and > characters, which made the thing not compile. Easy to fix for those who understand. Just double check it after you paste.

  2. user says:

    Run it how? Double clicking on it even with the extension .vbs just opens it in notepad again.

  3. I just tried it again and it seems to work fine on my end. Anyone else having any issues?

  4. Windowful says:

    Works great. I replaced the msgbox with an inputbox so that I could just copy and paste the result. This is the code.

    Inputbox "This is your Windows product key.","Key Finder", ConvertToKey(WshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionDigitalProductId"))

  5. jerry says:

    Worked like a champ! thanks

  6. Graham says:

    Use on other versions of Windows too, but display the product name along with the key:

    Inputbox WshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionProductName"),"Key Finder", ConvertToKey(WshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionDigitalProductId"))

  7. Mwiya Katunga says:

    thanks I think its working

  8. mikeb says:

    Thanks – this worked well for me except that I had errors until I realized I had to run it from an elevated command prompt or Explorer window so that it could read the registry key.

Skip to main content