• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

AutoIT Get windows and office key's

Status
Not open for further replies.

Skydno

NOT IN SPAIN
User
Joined
Jan 14, 2015
Messages
33
Reputation
0
Reaction score
319
Points
53
Credits
0
‎10 Years of Service‎
66%
[HIDE-THANKS]

Code:
>ConsoleWrite("Windows Key : " & @TAB & _DecodeProductKey("Windows") & @CRLF)
ConsoleWrite("Windows Key 4 : " & @TAB & _DecodeProductKey("Windows_DPid4") & @CRLF)
ConsoleWrite("Windows Default : " & @TAB & _DecodeProductKey("Windows_Def") & @CRLF)
ConsoleWrite("Windows Default 4 : " & @TAB & _DecodeProductKey("Windows_Def_DPid4") & @CRLF & @CRLF)


ConsoleWrite("Office XP Key : " & @TAB & _DecodeProductKey("Office XP") & @CRLF)
ConsoleWrite("Office 2003 Key : " & @TAB & _DecodeProductKey("Office 2003") & @CRLF)
ConsoleWrite("Office 2007 Key : " & @TAB & _DecodeProductKey("Office 2007") & @CRLF)
ConsoleWrite("Office 2010 x86 Key: " & @TAB & _DecodeProductKey("Office 2010 x86") & @CRLF)
ConsoleWrite("Office 2010 x64 Key: " & @TAB & _DecodeProductKey("Office 2010 x64") & @CRLF)


ConsoleWrite("Office 2013 x86 Key: " & @TAB & _DecodeProductKey("Office 2013 x86") & @CRLF)
ConsoleWrite("Office 2013 x64 Key: " & @TAB & _DecodeProductKey("Office 2013 x64") & @CRLF)






Func _DecodeProductKey($Product, $Offset = 0)
   Local $sKey[29], $Value = 0, $hi = 0, $n = 0, $i = 0, $dlen = 29, $slen = 15, $Result, $bKey, $iKeyOffset = 52, $RegKey


   Switch $Product


       Case "Windows"
           $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")




       Case "Windows_DPid4"
           $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId4")
           $iKeyOffset = 0x328


       Case "Windows_Def"
           $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId")


       Case "Windows_Def_DPid4"
           $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId4")
           $iKeyOffset = 0x328






       Case "Office XP"
           $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\10.0\Registration'
           If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\10.0\Registration'
           For $i = 1 To 100
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next




       Case "Office 2003"
           $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\11.0\Registration'
           If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\11.0\Registration'
           For $i = 1 To 100
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next




       Case "Office 2007"
           $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\12.0\Registration'
           If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\12.0\Registration'
           For $i = 1 To 100
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next




       Case "Office 2010 x86"
           $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\14.0\Registration'
           If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Registration'
           For $i = 1 To 100
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next
           $iKeyOffset = 0x328




       Case "Office 2010 x64"
           If @OSArch <> 'x64' Then Return SetError(1, 0, "Product not found")
           $RegKey = 'HKLM64\SOFTWARE\Microsoft\Office\14.0\Registration'
           For $i = 1 To 100
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next
           $iKeyOffset = 0x328




Case "Office 2013 x86"
           $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\15.0\Registration'
           If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Registration'
           For $i = 1 To 1024
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next
           $iKeyOffset = 0x328


       Case "Office 2013 x64"
           If @OSArch <> 'x64' Then Return SetError(1, 0, "Product not found")
           $RegKey = 'HKLM64\SOFTWARE\Microsoft\Office\15.0\Registration'
           For $i = 1 To 1024
               $var = RegEnumKey($RegKey, $i)
               If @error <> 0 Then ExitLoop
               $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId')
               If Not @error Then ExitLoop
           Next
           $iKeyOffset = 0x328




       Case Else
       Return SetError(1, 0, "Product not supported")


   EndSwitch


   If Not BinaryLen($bKey) Then Return ""


   Local $aKeys[binaryLen($bKey)]
   For $i = 0 To UBound($aKeys) - 1
       $aKeys[$i] = Int(BinaryMid($bKey, $i + 1, 1))
   Next


Local Const $isWin8 = BitAND(BitShift($aKeys[$iKeyOffset + 14], 3), 1)
$aKeys[$iKeyOffset + 14] = BitOR(BitAND($aKeys[$iKeyOffset + 14], 0xF7), BitShift(BitAND($isWin8, 2), -2))


   $i = 24
   Local $sChars = "BCDFGHJKMPQRTVWXY2346789", $iCur, $iX, $sKeyOutput, $iLast
   While $i > -1
       $iCur = 0
       $iX = 14
       While $iX > -1
$iCur = BitShift($iCur, -8)
$iCur = $aKeys[$iX + $iKeyOffset] + $iCur
           $aKeys[$iX + $iKeyOffset] = Int($iCur / 24)
           $iCur = Mod($iCur, 24)
           $iX -= 1
       WEnd
       $i -= 1
       $sKeyOutput = StringMid($sChars, $iCur + 1, 1) & $sKeyOutput
       $iLast = $iCur
   WEnd


   If $isWin8 Then
       $sKeyOutput = StringMid($sKeyOutput, 2, $iLast) & "N" & StringTrimLeft($sKeyOutput, $iLast + 1)
   EndIf


   Return StringRegExpReplace($sKeyOutput, '(\w{5})(\w{5})(\w{5})(\w{5})(\w{5})', '\1-\2-\3-\4-\5')


EndFunc   ;==>_DecodeProductKey
[/HIDE-THANKS]

 
Status
Not open for further replies.
Back
Top