here is a native solution without ShowKeyPlus, from a VBS translation
I couldn't manage the Binary array properly, so I introduced the "WScript.Shell" Object
If someone manages to do it, I'd be happy to see it.
;~ #RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global $info = ShowKeyPlus()
ConsoleWrite($info & @CRLF)
Func ShowKeyPlus()
Local $oShell, $sProductName, $sProductID, $sProductKey, $sProductData
$oShell = ObjCreate("WScript.Shell")
If @error Then
MsgBox(16, "Error", "Could not create WScript.Shell object.")
Exit
EndIf
$sProductName = $oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
$sProductID = $oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
Local $aDigitalID = $oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")
If Not IsArray($aDigitalID) Or UBound($aDigitalID) < 164 Then
MsgBox(16, "Error", "Could not read the DigitalProductId from the registry.")
Exit
EndIf
$sProductKey = ConvertToKey($aDigitalID)
$sProductData = "Product Name: " & $sProductName & @CRLF & _
"Product ID: " & $sProductID & @CRLF & _
"Installed Key: " & $sProductKey
Return $sProductData
EndFunc
Func ConvertToKey($aKeyBytes)
Local Const $iKeyOffset = 52
Local Const $sMaps = "BCDFGHJKMPQRTVWXY2346789"
Local $isWin8, $i, $j, $iCurrent, $sKeyOutput = "", $iLast
$isWin8 = BitAND(Int($aKeyBytes[66] / 6), 1)
$aKeyBytes[66] = BitOR(BitAND($aKeyBytes[66], 0xF7), BitShift(BitAND($isWin8, 2), 2))
For $i = 24 To 0 Step -1
$iCurrent = 0
For $j = 14 To 0 Step -1
$iCurrent = $iCurrent * 256
$iCurrent = $iCurrent + $aKeyBytes[$j + $iKeyOffset]
$aKeyBytes[$j + $iKeyOffset] = Floor($iCurrent / 24)
$iCurrent = Mod($iCurrent, 24)
Next
If $i > 0 Then $sKeyOutput = StringMid($sMaps, $iCurrent + 1, 1) & $sKeyOutput
$iLast = $iCurrent
Next
If $isWin8 = 1 Then
Local $sKeyPart1 = StringMid($sKeyOutput, 1, $iLast)
Local $sInsert = "N"
$sKeyOutput = $sKeyPart1 & $sInsert & StringMid($sKeyOutput, $iLast + 1)
EndIf
Return StringMid($sKeyOutput, 1, 5) & "-" & _
StringMid($sKeyOutput, 6, 5) & "-" & _
StringMid($sKeyOutput, 11, 5) & "-" & _
StringMid($sKeyOutput, 16, 5) & "-" & _
StringMid($sKeyOutput, 21, 5)
EndFunc