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
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

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.