bcording Posted March 15, 2004 Share Posted March 15, 2004 (edited) This is just an example of how to do it...You could rewrite it to return keys for office products as well. Once a RegEnum function is written you'll see an intelligent version to return office products. expandcollapse popupDim $Bin $Bin = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","DigitalProductID") InputBox("Product Key", "Your " & @OSVERSION & " product key is:", DecodeProductKey($bin), "", -1, 100, -1, -1) 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 Edited March 15, 2004 by bcording Link to comment Share on other sites More sharing options...
insanepyrokid Posted March 16, 2004 Share Posted March 16, 2004 Wow, works great. Nice little piece of random you got going there....too bad it doesnt work on Win98, i used it at school on 98 and it just returns all B's. Link to comment Share on other sites More sharing options...
bcording Posted March 16, 2004 Author Share Posted March 16, 2004 Win9x product ID is different...or at least in a different place. BTW I have tested the DecodeProductKey function with Windows 2000, Windows XP, Office XP Pro/Std, Project 2002, Virtual PC 2004 and Visual Studio 2003 Professional. When the Registry Enumeration function is complete these will all be added...till then. Link to comment Share on other sites More sharing options...
insanepyrokid Posted March 17, 2004 Share Posted March 17, 2004 Is there a way to distinguish windows xp home from windows xp pro? in the pop-up box it like to see which one it is. i guess i can search registry to try to find a distinguishable string. Link to comment Share on other sites More sharing options...
bcording Posted March 17, 2004 Author Share Posted March 17, 2004 (edited) In the registry look at HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions. ProductType: ServerNT = Server LanmanNT = Advanced Server WinNT = Professional or Home ProductSuite: Personal = Home Terminal Server = Terminal Server So if ProductType is WinNT and ProductSuite is Personal it is Home Edited March 17, 2004 by bcording Link to comment Share on other sites More sharing options...
insanepyrokid Posted March 18, 2004 Share Posted March 18, 2004 what if product type is WinNT and product suite is left blank? Link to comment Share on other sites More sharing options...
bcording Posted March 18, 2004 Author Share Posted March 18, 2004 If it's XP then it's Professional, otherwise it's Workstation Link to comment Share on other sites More sharing options...
insanepyrokid Posted March 18, 2004 Share Posted March 18, 2004 Thanks. With this little code i will finally have proof that my high school uses mostly pirated software. (the computer teachers already admit to using borland compilers w/o licenses and starcraft w/o legit keys...stupid school....not that im gunna do anything about it, but ive always had a hunch that they dont have the licenses for all thier windows (they have comps ranging from win95 to nt and xp, some with the all-too-popular pirated cd key....lol Link to comment Share on other sites More sharing options...
Gene Posted March 18, 2004 Share Posted March 18, 2004 (edited) Thanks. With this little code i will finally have proof that my high school uses mostly pirated software. (the computer teachers already admit to using borland compilers w/o licenses and starcraft w/o legit keys...stupid school....not that im gunna do anything about it, but ive always had a hunch that they dont have the licenses for all thier windows (they have comps ranging from win95 to nt and xp, some with the all-too-popular pirated cd key....lolThere is another, less nefarious possibility...A former employer regularly purchased (for example sake) 200 licenses and 10 CD sets. The 5 different IT teams would be given 2 CD sets each. They would build 1 each of the various PC classes in use, then Ghost them onto the others. So the ID and CD keys would legitimately be the same accross many PCs for any given flavor of software. Your situation may be different, but it is worth thinking about.Gene Edited March 18, 2004 by Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
bcording Posted March 18, 2004 Author Share Posted March 18, 2004 (edited) If he finds that a computer in his class is using a key readily found on the internet...it's a pretty good sign it's pirated. BTW this is pretty much the reason i posted this code. I'm using it at work as a meathod of finding out if there are any computers using products that don't conform to our volume license keys. Edited March 18, 2004 by bcording Link to comment Share on other sites More sharing options...
insanepyrokid Posted March 18, 2004 Share Posted March 18, 2004 two known xp keys are the one that i use on my computer, the #1 pirated key (FCKGW-----------...) Link to comment Share on other sites More sharing options...
cherdeg Posted September 29, 2009 Share Posted September 29, 2009 (edited) Sorry to bump this years after...but in my case a wrong license key is returned by the function. Were there any changes since SP3 on XP? I use the following code: expandcollapse popupLocal $b_BinaryKey = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","DigitalProductID") Local $s_ProductKey = _DecodeProductKey($b_BinaryKey) $i_ButtonCliecked = MsgBox(36, "Change Windows Product Key", "Your current" & @OSVERSION & " product key is: " & @CRLF & @CRLF & $s_ProductKey & @CRLF & @CRLF & "Do you really want to change it?") If $i_ButtonCliecked = 6 Then Dim $s_VOL_PROD_KEY = InputBox("New Volume License Key", "Please enter the new key for this installation: ") If @error Then Exit $s_VOL_PROD_KEY = StringReplace($s_VOL_PROD_KEY, "-", "") $o_WMIservice = ObjGet("winmgmts:{impersonationLevel=impersonate}") $o_WPAinstances = $o_WMIservice.InstancesOf("win32_WindowsProductActivation") for $o_Item in $o_WPAinstances $s_result = $o_Item.SetProductKey($s_VOL_PROD_KEY) If $s_result = 0 Then MsgBox(64, "SUCCESS", "The product key was changed.") Else MsgBox(16, "ERROR", "An error has happened, check if product key was changed.") EndIf Next EndIf 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 I found the solution (due to tranceXXX): If @extended = 3 Then $b_BinaryKey = Hex($b_BinaryKey) Edited October 1, 2009 by cherdeg Link to comment Share on other sites More sharing options...
sheeva Posted October 4, 2009 Share Posted October 4, 2009 Work perfectly Thank's Link to comment Share on other sites More sharing options...
PeterAtkin Posted January 12, 2010 Share Posted January 12, 2010 Seems this does not work for Windows 7, and i seem unable to understand where the If @extended = 3 Then $b_BinaryKey = Hex($b_BinaryKey) should go! if that could be made transparent then is should be a doable task to make it windows 7 compliant.. [topic='115020'] AD Domain Logon Script[/topic] 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