Modify ↓
#805 closed Bug (No Bug)
Don't really know what command is causing the problem
| Reported by: | Emiel Wieldraaijer | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.0.0 | Severity: | None |
| Keywords: | Cc: |
Description
I use a script from Danny35d to display office and windows serials.
After updating to 3.3.0.0 the returned information is not correct anymore.
#include <Array.au3>
$HKLM = "HKEY_LOCAL_MACHINE"
If @OSArch = "X64" Then
$HKLM &= "64"
EndIf
$OfficeKey = _GetOfficeKey()
_ArrayDisplay($OfficeKey, 'Office Key')
$HKLM = "HKEY_LOCAL_MACHINE"
If @OSArch = "X64" Then
$HKLM &= "64"
EndIf
;===============================================================================
;
; Function Name: _GetWindowsKey()
; Description: gets the Windows DigitalProductID from the registry
; Parameter(s): none
; Requirement(s): none
; Return Value(s): Returns the binary Windows DigitalProductID as stored in the registry
; Author(s): Danny35d
;
;===============================================================================
; TBD: Error checking and SetError
Func _GetWindowsKey($sRemoteComputer = '')
Dim $aKeys[2][5]
If $sRemoteComputer <> '' Then $sRemoteComputer = '\\' & StringReplace($sRemoteComputer, '\', '') & '\'
Local Const $sRegKey = $sRemoteComputer & $HKLM & '\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$aKeys[0][0] = 1
$aKeys[1][0] = RegRead($sRegKey, 'ProductName')
$aKeys[1][1] = RegRead($sRegKey, 'ProductID')
$aKeys[1][2] = _DecodeProductKey(RegRead($sRegKey, 'DigitalProductID'))
$aKeys[1][3] = RegRead($sRegKey, 'RegisteredOwner')
$aKeys[1][4] = RegRead($sRegKey, 'RegisteredOrganization')
Return($aKeys)
EndFunc ;==>_GetWindowsKey
;===============================================================================
;
; Function Name: _GetOfficeKey()
; Description: gets the Office DigitalProductID from the registry
; Parameter(s): none
; Requirement(s): none
; Return Value(s): Returns the binary 2003 Office DigitalProductID as stored in the registry
; Author(s): Danny35d
;
;===============================================================================
; TBD: Error checking and SetError
Func _GetOfficeKey($sRemoteComputer = '')
Dim $aKeys[1][3]
If $sRemoteComputer <> '' Then $sRemoteComputer = '\\' & StringReplace($sRemoteComputer, '\', '') & '\'
Local $sRegKey1 = $sRemoteComputer & $HKLM & '\SOFTWARE\Microsoft\Office'
Local $sRegKey2 = $sRemoteComputer & $HKLM & '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
Local $iCount1 = 1, $iCount2 = 1
While 1
$sKey1 = RegEnumKey($sRegKey1, $iCount1)
If @error <> 0 Then ExitLoop
While 1
$ProductID = ''
$ProductName = ''
$DigitalProductID = ''
$sKey2 = RegEnumKey($sRegKey1 & '\' & $sKey1 & '\Registration', $iCount2)
If @error <> 0 Then ExitLoop
$ProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductID')
$ProductName = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName')
$DigitalProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID')
$InstallPath = StringTrimRight((RegRead ($sRegKey1 & '\' & $sKey1 & '\Common\InstallRoot', 'Path')),1)
$ProductVersion = RegRead($sRegKey1 & '\' & $sKey1 & '\Common\Productversion', 'Lastproduct')
$OfficeLanguage = StringRight(Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Common\LanguageResources', 'SKULanguage')),4)
If $ProductName = '' Then $ProductName = RegRead($sRegKey2 & '\' & $sKey2, 'DisplayName')
$DigitalProductID = _DecodeProductKey($DigitalProductID)
If $DigitalProductID <> 'BBBBB-BBBBB-BBBBB-BBBBB-BBBBB' Then
ReDim $aKeys[UBound($aKeys) + 1][6]
$aKeys[0][0] = UBound($aKeys) - 1
$aKeys[UBound($aKeys) - 1][0] = $ProductName
$aKeys[UBound($aKeys) - 1][1] = $ProductID
$aKeys[UBound($aKeys) - 1][2] = $DigitalProductID
$aKeys[UBound($aKeys) - 1][3] = $InstallPath
$aKeys[UBound($aKeys) - 1][4] = $ProductVersion
$aKeys[UBound($aKeys) - 1][5] = $OfficeLanguage
EndIf
$iCount2 += 1
WEnd
$iCount1 += 1
WEnd
Return($aKeys)
EndFunc ;==>_GetOfficeKey
;===============================================================================
;
; Function Name: _DecodeProductKey()
; Description: decodes the PID to get the product key
; Parameter(s): $BinaryDPID - the PID as stored in registry
; Requirement(s): none
; Return Value(s): Returns the decoded Windows/Office/Visual studio/etc. product key
; Author(s): found this in the Forum, who made it?!
;
;===============================================================================
Func _DecodeProductKey($BinaryDPID)
Local $bKey[15]
Local $sKey[29]
Local $Digits[24]
Local $Value = 0
Local $hi = 0
Local $n = 0
Local $i = 0
Local $dlen = 29
Local $slen = 15
Local $Result
$Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
$binaryDPID = StringMid($binaryDPID, 105, 30)
For $i = 1 To 29 Step 2
$bKey[Int($i / 2) ] = Dec(StringMid($binaryDPID, $i, 2))
Next
For $i = $dlen - 1 To 0 Step - 1
If Mod(($i + 1), 6) = 0 Then
$sKey[$i] = "-"
Else
$hi = 0
For $n = $slen - 1 To 0 Step - 1
$Value = BitOR(BitShift($hi, -8), $bKey[$n])
$bKey[$n] = Int($Value / 24)
$hi = Mod($Value, 24)
Next
$sKey[$i] = $Digits[$hi + 1]
EndIf
Next
For $i = 0 To 28
$Result = $Result & $sKey[$i]
Next
Return $Result
EndFunc ;==>_DecodeProductKey
Attachments (0)
Change History (2)
comment:1 Changed 17 years ago by Valik
- Resolution set to No Bug
- Status changed from new to closed
comment:2 Changed 17 years ago by Jpm
perhaps
If IsBinary($BinaryDPID) Then $binaryDPID = StringMid($binaryDPID, 107, 30) Else $binaryDPID = StringMid($binaryDPID, 105, 30) EndIf
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

Before you post another ticket, read WikiStart.