JFX Posted August 12, 2011 Share Posted August 12, 2011 (edited) all credits to bcording '?do=embed' frameborder='0' data-embedContent>> Just a more Up-to-date version including office: expandcollapse popupConsoleWrite("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 Edited May 30, 2014 by JFX Trong 1 Link to comment Share on other sites More sharing options...
UEZ Posted August 12, 2011 Share Posted August 12, 2011 Seems to be working properly - getting results for MS Office 2010 x64! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Maffe811 Posted August 12, 2011 Share Posted August 12, 2011 i got results for Office 2010 x86 and windows [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
Chimaera Posted August 12, 2011 Share Posted August 12, 2011 Has anyone managed to perfect getting the proper OS key in Vista and 7, many claim to do it. Ive only seen 2 programs that can do it in vista and none in 7 Nice work JFX If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JFX Posted August 12, 2011 Author Share Posted August 12, 2011 Has anyone managed to perfect getting the proper OS key in Vista and 7, many claim to do it.Ive only seen 2 programs that can do it in vista and none in 7Would you mean, does it not works for you? Do you get a wrong Product key for windows or "Product not found" error? Link to comment Share on other sites More sharing options...
Maffe811 Posted August 12, 2011 Share Posted August 12, 2011 Has anyone managed to perfect getting the proper OS key in Vista and 7, many claim to do it.Ive only seen 2 programs that can do it in vista and none in 7Nice work JFXI got a result, i don't know what the code is, so i don't know if its correct... [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted August 13, 2011 Share Posted August 13, 2011 Has anyone managed to perfect getting the proper OS key in Vista and 7, many claim to do it.Ive only seen 2 programs that can do it in vista and none in 7Nice work JFXWhen your OS is preinstalled or when using a recovery cd, you will get wrong results Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
BrewManNH Posted August 13, 2011 Share Posted August 13, 2011 When your OS is preinstalled or when using a recovery cd, you will get wrong resultsYou won't get "wrong" results, you'll just get a different key than the one on the Product Key label on the computer. That's because the key used to register the OS is the OEM key, and the COA key is what Microsoft sold to the OEM so that you have proof that the OS is legit. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted August 14, 2011 Share Posted August 14, 2011 (edited) You won't get "wrong" results, you'll just get a different key than the one on the Product Key label on the computer. That's because the key used to register the OS is the OEM key, and the COA key is what Microsoft sold to the OEM so that you have proof that the OS is legit.Thats what im getting i tested some at work and it gives correct key, the laptops at work seem to be the worst offenders for the reason aboveIs there a way to get both OEM key and COA key on the ones that dont show?Well so it shows the actual key that matches the sticker is what i mean.Good work though will make my life easier Edited August 14, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2011 Share Posted August 14, 2011 The code on the COA label is usually never used, and I'd say probably a good proportion of them never are. The OEM code is the one that's used to register the OS installation never the label, if you use their restore software. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted August 14, 2011 Share Posted August 14, 2011 (edited) Thats the issue lots that we get have damaged / unreadable labels and no restore discs so a way to get the right key would be real usefull Edited August 14, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Meitantei Posted August 14, 2011 Share Posted August 14, 2011 Thanks, I needed It works correctly. At least I speak from "x64" Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted August 14, 2011 Share Posted August 14, 2011 You won't get "wrong" results, you'll just get a different key than the one on the Product Key label on the computer. That's because the key used to register the OS is the OEM key, and the COA key is what Microsoft sold to the OEM so that you have proof that the OS is legit.Ohhhhhhh.. so a different key .. instead of the one on the sticker isn't wrong ?? so 1 + 1 = 3 .. because is say so .. Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2011 Share Posted August 14, 2011 Ohhhhhhh.. so a different key .. instead of the one on the sticker isn't wrong ?? so 1 + 1 = 3 .. because is say so ..I'm not sure if that was your way of trying to be insulting or just trying to be humorous, but what I said is accurate. The result isn't wrong because it doesn't match the COA label it's just not the one on the label, what you're retrieving is the OEM key. The key on the label will almost never be used by anyone, ever, so you will almost never get that key from the registry.I've worked on Dell, HP, Compaq, Sony, Toshiba, NEC and many other brands, and I've never had to use the key on the label to register the installation of Windows if I've had the restore disks. If I don't have those disks, I can legally install the same OS as the one on the label and use that key, and then you'll be able to grab that key from the registry.So in this case, the result is correct if it's the OEM key you retrieve, because that is the one it was registered with. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted August 14, 2011 Share Posted August 14, 2011 Ohhhhhhh.. so a different key .. instead of the one on the sticker isn't wrong ?? so 1 + 1 = 3 .. because is say so ..Im not quite sure where you are going with this Emeil, we are talking about genuine keys here not anything elseThe key on the label will almost never be used by anyone, ever, so you will almost never get that key from the registry.We use that label key all the time, mainly because the customers dont make the discs or have accessible recovery partitionsIf I don't have those disks, I can legally install the same OS as the one on the label and use that key, and then you'll be able to grab that key from the registry.So in this case, the result is correct if it's the OEM key you retrieve, because that is the one it was registered with.As long as i can still use the OEM key to reinstall windows and its allowed by MS that's fine by me, because when the keys worn and you cant use the partition the customers get mightily pissed off paying for windows again.Which is what im trying to avoid.Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JFX Posted August 15, 2011 Author Share Posted August 15, 2011 Have added the DefaultProductKey and DigitalProductId4, hope this helps. Link to comment Share on other sites More sharing options...
Chimaera Posted August 15, 2011 Share Posted August 15, 2011 (edited) Thanks for the additions JFX ill compile and do some testing at work for you and report back For those that want a Gui for it #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; ------------------------------------------------------------------------------ $GUI_Start = GUICreate("Product Key Finder", 200, 120, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $button1 = GUICtrlCreateButton(" Windows Key Search ", 27, 25, 150) GUICtrlSetFont(-1, 10, "", "", "Tahoma") $button2 = GUICtrlCreateButton(" Office Key Search ", 27, 65, 150) GUICtrlSetFont(-1, 10, "", "", "Tahoma") GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 MsgBox(0, "Available Windows Licence Keys", "Windows Key : " & @TAB & @TAB & _DecodeProductKey("Windows") & @CRLF & @CRLF & _ "Windows Key DPid4 : " & @TAB & _DecodeProductKey("Windows_DPid4") & @CRLF & @CRLF & _ "Windows Default : " & @TAB & _DecodeProductKey("Windows_Def") & @CRLF & @CRLF & _ "Windows Default DPid4 : " & @TAB & _DecodeProductKey("Windows_Def_DPid4")) Case $button2 MsgBox(0, "Available Office Licence Keys", "Office XP Key : " & @TAB & @TAB & _DecodeProductKey("Office XP") & @CRLF & @CRLF & _ "Office 2003 Key : " & @TAB & @TAB & _DecodeProductKey("Office 2003") & @CRLF & @CRLF & _ "Office 2007 Key : " & @TAB & @TAB & _DecodeProductKey("Office 2007") & @CRLF & @CRLF & _ "Office 2010 x86 Key: " & @TAB & _DecodeProductKey("Office 2010 x86") & @CRLF & @CRLF & _ "Office 2010 x64 Key: " & @TAB & _DecodeProductKey("Office 2010 x64")) EndSwitch WEnd Enjoy Edited August 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Nunos Posted August 27, 2011 Share Posted August 27, 2011 I am getting the below error when I try to run Chimera's code any idea what I am doing wrong? Product Key.au3(20,119) : ERROR: _DecodeProductKey(): undefined function. MsgBox(0, "Available Windows Licence Keys", "Windows Key : " & @TAB & @TAB & _DecodeProductKey("Windows") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Nunos\Desktop\Scripts\AutoIT\Product Key.au3 - 1 error(s), 0 warning(s) Link to comment Share on other sites More sharing options...
Valuater Posted August 27, 2011 Share Posted August 27, 2011 I am getting the below error when I try to run Chimera's code any idea what I am doing wrong? Product Key.au3(20,119) : ERROR: _DecodeProductKey(): undefined function. MsgBox(0, "Available Windows Licence Keys", "Windows Key : " & @TAB & @TAB & _DecodeProductKey("Windows") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Nunos\Desktop\Scripts\AutoIT\Product Key.au3 - 1 error(s), 0 warning(s) You have to combine the two codes GUI and Functions. This works... expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; ------------------------------------------------------------------------------ $GUI_Start = GUICreate("Product Key Finder", 200, 120, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $button1 = GUICtrlCreateButton(" Windows Key Search ", 27, 25, 150) GUICtrlSetFont(-1, 10, "", "", "Tahoma") $button2 = GUICtrlCreateButton(" Office Key Search ", 27, 65, 150) GUICtrlSetFont(-1, 10, "", "", "Tahoma") GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 MsgBox(0, "Available Windows Licence Keys", "Windows Key : " & @TAB & @TAB & _DecodeProductKey("Windows") & @CRLF & @CRLF & _ "Windows Key DPid4 : " & @TAB & _DecodeProductKey("Windows_DPid4") & @CRLF & @CRLF & _ "Windows Default : " & @TAB & _DecodeProductKey("Windows_Def") & @CRLF & @CRLF & _ "Windows Default DPid4 : " & @TAB & _DecodeProductKey("Windows_Def_DPid4")) Case $button2 MsgBox(0, "Available Office Licence Keys", "Office XP Key : " & @TAB & @TAB & _DecodeProductKey("Office XP") & @CRLF & @CRLF & _ "Office 2003 Key : " & @TAB & @TAB & _DecodeProductKey("Office 2003") & @CRLF & @CRLF & _ "Office 2007 Key : " & @TAB & @TAB & _DecodeProductKey("Office 2007") & @CRLF & @CRLF & _ "Office 2010 x86 Key: " & @TAB & _DecodeProductKey("Office 2010 x86") & @CRLF & @CRLF & _ "Office 2010 x64 Key: " & @TAB & _DecodeProductKey("Office 2010 x64")) EndSwitch WEnd Func _DecodeProductKey($Product) Local $bKey[15], $sKey[29], $Digits[24], $Value = 0, $hi = 0, $n = 0, $i = 0, $dlen = 29, $slen = 15, $Result, $BinaryDPID, $KeyPos = 0x34 * 2 + 3, $RegKey $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "") Switch $Product Case "Windows" $BinaryDPID = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId") Case "Windows_DPid4" $BinaryDPID = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId4") $KeyPos = 0x328 * 2 + 3 Case "Windows_Def" $BinaryDPID = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId") Case "Windows_Def_DPid4" $BinaryDPID = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId4") $KeyPos = 0x328 * 2 + 3 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 $BinaryDPID = 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 $BinaryDPID = 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 $BinaryDPID = 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 $BinaryDPID = RegRead($RegKey & '\' & $var, 'DigitalProductId') If Not @error Then ExitLoop Next $KeyPos = 0x328 * 2 + 3 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 $BinaryDPID = RegRead($RegKey & '\' & $var, 'DigitalProductId') If Not @error Then ExitLoop Next $KeyPos = 0x328 * 2 + 3 Case Else Return SetError(1, 0, "Product not supported") EndSwitch If StringLen($BinaryDPID) < 29 Then Return SetError(1, 0, "Product not found") $BinaryDPID = StringMid($BinaryDPID, $KeyPos) 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 Nice work guys tested great on my Comp. Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted August 28, 2011 Share Posted August 28, 2011 I'm not sure if that was your way of trying to be insulting or just trying to be humorous, but what I said is accurate. The result isn't wrong because it doesn't match the COA label it's just not the one on the label, what you're retrieving is the OEM key. The key on the label will almost never be used by anyone, ever, so you will almost never get that key from the registry.I've worked on Dell, HP, Compaq, Sony, Toshiba, NEC and many other brands, and I've never had to use the key on the label to register the installation of Windows if I've had the restore disks. If I don't have those disks, I can legally install the same OS as the one on the label and use that key, and then you'll be able to grab that key from the registry.So in this case, the result is correct if it's the OEM key you retrieve, because that is the one it was registered with.It was ment humorous. 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