blakel Posted May 2, 2009 Share Posted May 2, 2009 Here is a function I translated from a vbs script I found somewhere. It was likely translated from Magic Jelly Bean Keyfinder. It allows one to recover the CD key from the windows registry for reinstall, license auditing, etc. I have only tested it with WinXP 32-bit SP3. It will likely work with 2k on, but not sure. I also suspect the same algorithm will work with office and other M$ products. expandcollapse popupFunc GetWXPCDKey($remotePC = ".") Local $dpi = RegRead("\\" & $remotePC & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","DigitalProductId") $dpi = StringMid(String($dpi),107,32) Local $ha[16] For $i = 0 To 15 $ha[$i] = Number("0x" & StringMid($dpi,($i*2)+1,2) ) Next Local $table[24] $table [0] = "B" $table [1] = "C" $table [2] = "D" $table [3] = "F" $table [4] = "G" $table [5] = "H" $table [6] = "J" $table [7] = "K" $table [8] = "M" $table [9] = "P" $table [10] = "Q" $table [11] = "R" $table [12] = "T" $table [13] = "V" $table [14] = "W" $table [15] = "X" $table [16] = "Y" $table [17] = "2" $table [18] = "3" $table [19] = "4" $table [20] = "6" $table [21] = "7" $table [22] = "8" $table [23] = "9" Local $key = "" For $i = 1 To 25 Local $a = 0 For $j = 15 To 0 Step -1 Local $b = BitOr($a * 256,$ha[$j]) $a = Mod($b,24) $ha[$j] = $b / 24 Next $key = $table[$a] & $key Next Return StringLeft($key,5) & "-" & StringMid($key,6,5) & "-" & StringMid($key,11,5) & "-" & StringMid($key,16,5) & "-" & StringRight($key,5) EndFunc Example: $pc = InputBox("Get CD Key","Name/IP: ") MsgBox(0,GetWXPProductName($pc) & " " & GetWXPVer($pc),"CDKey: " & GetWXPCDKey($pc) ) Func GetWXPProductName($remotePC = ".") Return RegRead("\\" & $remotePC & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName") EndFunc Func GetWXPVer($remotePC = ".") Return RegRead("\\" & $remotePC & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentVersion") EndFunc Hope you find it useful. Link to comment Share on other sites More sharing options...
eltorro Posted May 4, 2009 Share Posted May 4, 2009 (edited) I hope you don't mind, I took the liberty to update your code a little. Func GetWXPCDKey($remotePC = ".") Local $dpi = RegRead("\\" & $remotePC & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId") If @error Then Return SetError(1, 0, "") Local $table = StringSplit("BCDFGHJKMPQRTVWXY2346789", "", 2) Local $a, $b, $key = "", $ha[16] For $i = 0 To 15 $ha[$i] = BinaryMid($dpi, ($i + 53), 1) Next For $i = 0 To 24 $a = 0 For $j = 15 To 0 Step -1 $b = BitOR($a * 256, $ha[$j]) $a = Mod($b, 24) $ha[$j] = $b / 24 Next If (Not Mod($i, 5)) And $i Then $key = "-" & $key $key = $table[$a] & $key Next Return $key EndFunc ;==>GetWXPCDKey edit: fixed a typo. Edited May 4, 2009 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
blakel Posted May 7, 2009 Author Share Posted May 7, 2009 I hope you don't mind, I took the liberty to update your code a little.Not at all, that is what this place of the forum is for.Good improvements. Link to comment Share on other sites More sharing options...
lsakizada Posted May 7, 2009 Share Posted May 7, 2009 (edited) See this URL with similar functionality for office:) Edited May 7, 2009 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
jeantje Posted May 7, 2009 Share Posted May 7, 2009 (edited) Here is a function I translated from a vbs script I found somewhere. It was likely translated from Magic Jelly Bean Keyfinder. It allows one to recover the CD key from the windows registry for reinstall, license auditing, etc. I have only tested it with WinXP 32-bit SP3. It will likely work with 2k on, but not sure. I also suspect the same algorithm will work with office and other M$ products. Code Removed Hope you find it useful. I also made an u3 version but it's a bit different because it only get's local keys and then it display's it with MsgBox So. Download U3: WCK_U3.ZIP Edited May 7, 2009 by jeantje Link to comment Share on other sites More sharing options...
KenNichols Posted May 7, 2009 Share Posted May 7, 2009 Thanks! I used CODE$pc = @ComputerName MsgBox(0,"Windows Key",GetWXPProductName($pc) & " " & @OSServicePack & @CRLF & "CDKey: " & GetWXPCDKey($pc)) [topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner! 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