Emiel Wieldraaijer Posted February 6, 2009 Share Posted February 6, 2009 Hi All, I use the following script to from Danny35d to retrieve Office and Windows Serials but after updating to AutoIt version 3.3.0.0 another serial is displayed 3.2.12.1 displays the serial perfect. expandcollapse popup#include <Array.au3> $OfficeKey = _GetOfficeKey() _ArrayDisplay($OfficeKey, 'Office Key') ;=============================================================================== ; ; 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 & 'HKEY_LOCAL_MACHINE\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 & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office' Local $sRegKey2 = $sRemoteComputer & 'HKEY_LOCAL_MACHINE\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 Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
rover Posted February 7, 2009 Share Posted February 7, 2009 (edited) Hi All, I use the following script to from Danny35d to retrieve Office and Windows Serials but after updating to AutoIt version 3.3.0.0 another serial is displayed 3.2.12.1 displays the serial perfect. expandcollapse popup#include <Array.au3> $OfficeKey = _GetOfficeKey() _ArrayDisplay($OfficeKey, 'Office Key') ;=============================================================================== ; ; 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 & 'HKEY_LOCAL_MACHINE\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 & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office' Local $sRegKey2 = $sRemoteComputer & 'HKEY_LOCAL_MACHINE\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 @Emiel it's a gotcha change change this line in _GetOfficeKey() Edit: left out slash on code tag $DigitalProductID = Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID')) check if any of the other reg reads are binary RegRead() When reading a REG_BINARY key the result is a binary datatype (in previous versions it was a string of hex characters). History from helpfile - 24th December, 2008 - v3.3.0.0 Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced. be seeing you Edited February 7, 2009 by rover I see fascists... Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted February 7, 2009 Author Share Posted February 7, 2009 @Rover Thanks i overlooked the RegRead changes Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now