Recently I got a question about Embedded License keys for Windows client OS systems.
These are systems with a Windows license key embedded in the BIOS.
If you install Windows on a system with an embedded key, it will automatically install this key and activate it.
There are several ways to get the Original License Key from a Windows machine.
- Powershell (PS);
- Command Prompt (CMD);
- Windows Scripting Host (VBS).
But there is a little problem here. The key is stored as an encrypted registry key. With the first three tools this is not a problem, but with Windows 7 only the last tool, vbs scripting, is possible.
And then we have to do a little conversion
I will show how!
- Powershell (PS)Open an administrative Powershell windows and type:
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey - Command Prompt (CMD)Open an administrative Powershell windows and type:
wmic path softwarelicensingservice get OA3xOriginalProductKey - Windows Scripting Host (VBS)
If you run these commands in a pre-Windows 10 environment then you get a blank result!
But the key will still be there, if you have a activated device.
This can come in very handy with CMDB or other inventarisation purposes.So where is it and how to handle this?
This script reads the Registry key and converts this to the correct format.
You will get the product Key which is installed on that system! GOOD
Set oShell = CreateObject(“WScript.Shell”)
Set oFSO=CreateObject(“Scripting.FileSystemObject”)outFile=”C:\Temp\Key.txt”
Set oFile = oFSO.CreateTextFile(outFile, True)
oFile.Write ConvertToKey(oShell.RegRead(“HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId”)) & vbCrLf
oFile.CloseFunction ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = “BCDFGHJKMPQRTVWXY2346789”Do
Cur = 0
x = 14Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutputIf (((29 – i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = “-” & KeyOutput
End IfLoop While i >= 0
ConvertToKey = KeyOutput
End Function
Happy Reading keys.