Mit Autoit Windows 8/8.1 Key auslesen

  • Keine Ahnung welches Script du getestet hast, aber das hier funktioniert von XP bis 8.1 völlig problemlos:

    Spoiler anzeigen
    [autoit]

    ConsoleWrite("Windows Key : " & @TAB & _DecodeProductKey("Windows") & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Switch $Product

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Case "Office 2010 x64"
    IF @OSArch <> 'x64' Then 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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    IF Not BinaryLen($bKey) Then Return ""

    [/autoit] [autoit][/autoit] [autoit]

    Local $aKeys[BinaryLen($bKey)]
    For $i = 0 To UBound($aKeys) - 1
    $aKeys[$i] = Int(BinaryMid($bKey, $i + 1, 1))
    Next
    Local Const $isWin8 = BitAND(Int($aKeys[66]) / 6, 1)
    $aKeys[66] = BitOR(BitAND($aKeys[66], 0xF7), BitAND($isWin8, 2) * 4)
    $i = 24
    Local $sChars = "BCDFGHJKMPQRTVWXY2346789", $iCur, $iX, $sKeyOutput, $iLast
    While $i > -1
    $iCur = 0
    $iX = 14
    While $iX > -1
    $iCur *= 256
    $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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]
  • Genau sowas hatte ich gesucht, Danke! Ich hatte so wie es aussieht einen ganz anderen.. :huh:

    Aber was genau ist der Unterschied

    [autoit]

    ConsoleWrite("Windows Key : " & @TAB & _DecodeProductKey("Windows") & @CRLF)

    [/autoit][autoit][/autoit][autoit]

    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)

    [/autoit]


    zwischen den "Windows Key", "Windows Key4", "Windows Default" & "Windows Default 4"? ?(