Jump to content



Photo

Windows and Office key


  • Please log in to reply
53 replies to this topic

#21 urie

urie

    Seeker

  • Active Members
  • 15 posts

Posted 28 August 2011 - 06:04 PM

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

Some info

Definition of OEM:

The term, OEM (original equipment manufacturer) refers to companies that make products for others to repackage and sell. Resellers buy OEM products in bulk, minus the costly retail packaging that comes with individually sold units. The product itself is essentially the same as its more expensive, retail-packaged sibling. OEM products are used in many industries, but are perhaps most prevalent in electronics.

Generally, dealers of OEM products add something of value before reselling the merchandise. An OEM vendor that does this is known as a "value added reseller" (VAR). A VAR might build components, sub-systems, or systems from quality OEM parts. OEM goods allow VARs a wide range of creative marketing choices, which permits smaller dealers to be competitive in the marketplace.

OEM software will have different product numbers than retail packages, and support may be provided by the VAR, rather than the maker of the software. Functionally, OEM and retail versions of software should be essentially the same.

Two kinds of OEM Product Keys:

OEM SLP Keys:
* OEM SLP (System-Locked Pre-installation) keys are only issued to the big manufacturers such as Dell, Asus, Sony, etc.

* These are the only keys that are able to bypass activation that is, perform offline activation without contacting Microsoft.

* They will work with any OEM SLP system, regardless of the OEM system's brand i.e. Product Keys are not brand specific.

OEM NONSLP Keys:
* Similar to Retail, but distributed and supported by an OEM. Needs activation by phone or online and they are not brand specific. .

OEM COA Keys:
* OEM COA keys (Certificate of Authentication) are regular OEM keys that require activation, either by phone or online and they are not brand specific.
(you will find the sticker with the key underneath you Laptop or on the side of you PC)

* These keys will work in general same as Retail or Upgrade keys and can be used only once.

OEM SLP Product Keys activation:
* You need is an OEM SLP Product Key that matches the version of Windows Vista you have installed or are going to install.
(Home Basic, Home Premium, Business or Ultimate), plus the OEM certificate matching the SLIC table

* The OEM SLP Product Key does not have to match the OEM-brand certificate nor the OEM-brand BIOS ACPI_SLIC information.
(The only ones that need to match are the OEM-brand certificate and the OEM-brand BIOS ACPI_SLIC information.)

* SLP activation doesn't work with Vista Release Candidates or Vista Beta versions. Only the final version (RTM, Retail or OEM).

i.e.: A+B+C = Vista Activated Offline
OEM SLP Key + OEM Certificate + Full SLIC Table = Vista Activated Offline
If one (A,B or C) is missing, activation will fail!





#22 Nunos

Nunos

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 28 August 2011 - 06:42 PM

Thank you Valuater for the explanation and example :mellow:

And thank you to the creators of this script it works great here on WIndows 7 Business (x86) and (x64).

#23 NDog

NDog

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 12 September 2011 - 10:32 PM

I'm using this on fresh Windows 7 Professional SP1 MAK activated. Windows Key returns BBBBB-BBBBB-BBBBB-BBBBB-BBBBB and the Windows Default key returns HYF8J-CVRMY-...., which is the default microsoft key you can use for 31 days trial. Im writing a script to backup the token and use for offline reactivation on machines in some of my sites for reimaging purposes. (proxy stuff is a headache)

Has anyone else here had success with this and Windows 7 Pro MAK activated? If it is not possible then I will have to embed the key for each site into the autoit script and compile an exe for each site (not secure) or backup the registy key section for each machine (untested but may work). I prefer to return Windows Key, but then if that is not possible I have to work around that.....

#24 JFX

JFX

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 13 September 2011 - 06:34 PM

Sorry MAK can't be recovered with this script. unsure where and how key is stored in MAK activation.

#25 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 1,520 posts

Posted 10 October 2011 - 02:08 PM

I'm curious can this be altered to read a drive plugged in and external drive?

On another program ive used it had a load hive option and you gave the external drive location and the windows folder and it read the key from that

Common scenario for us licence key is worn so not usable, hard drive wont boot OS so cant recover that way, but drive is accessible in a caddy/external drive so reading the hive that way would be very usefull sometimes to get the key back.
I don't know much about registry so i wouldn't know how to proceed loading another registry hive.

Any thoughts?

EDIT found this, not sure if it helps though as this is doing it manually

Load the hive.
To load Local_machine hive,
Open regedit > Click "HKEY_LOCAL_MACHINE"
File > Load Hive > Browse to the file
Give it a name > then do what yoy want to do with it
Click on the loaded hive > File > Unload Hive

To load a Users hive,
Open regedit > Click "HKEY_USERS"
File > Load Hive > Browse to the file
Give it a name > then do what yoy want to do with it
Click on the loaded hive > File > Unload Hive


Edited by Chimaera, 10 October 2011 - 02:17 PM.


#26 storme

storme

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 754 posts

Posted 11 October 2011 - 12:03 AM

On another program ive used it had a load hive option and you gave the external drive location and the windows folder and it read the key from that

Common scenario for us licence key is worn so not usable, hard drive wont boot OS so cant recover that way, but drive is accessible in a caddy/external drive so reading the hive that way would be very usefull sometimes to get the key back.
I don't know much about registry so i wouldn't know how to proceed loading another registry hive.

Any thoughts?


I load an OLD program called ERUNT onto all my computers (works on XP to Win7).
It backs up the registry and even leaves a restore program in each of backup folders.
One little trouble is UAC stops it working completly (i.e NO UAC Prompts at all just an error from ERUNT)
In your scenario you would boot with a winpe or similar, run the restore program in the directory of the most recent backup and you have the registry back in place. It's saved a lot of my systems from being reinstalled for a simple registry glitch. :graduated:

Hope you have a great day!
John Morrison

#27 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 1,520 posts

Posted 11 October 2011 - 07:12 AM

The problem for me atm is i cant boot the pc at all the drive is that twitchy, but if you chuck it in a caddy a different system OS is able to access the drive albeit not very well.
I just wondered if it was possible to have the ability to point to the registry hive on the damaged drive using the different OS and get the key from the damaged drive using the earlier code.

Well i know its possible, its just how.

Edited by Chimaera, 11 October 2011 - 07:13 AM.


#28 storme

storme

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 754 posts

Posted 11 October 2011 - 10:17 AM

The problem for me atm is i cant boot the pc at all the drive is that twitchy, but if you chuck it in a caddy a different system OS is able to access the


Sorry I missed that it was a current problem :graduated: well maybe for next time Erunt can help.

You can use REGEDT32 to mount external registry (I've never done it myself, but here is what i've found)
(File -> Load Hive Check the help file for full details.

User registry HKEY_CURRENT_USER c:\documents and settings\{username}\NTUSER.DAT
Other registry \windows\system32\config\????.data

Good Luck
John Morrison

#29 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 1,520 posts

Posted 11 October 2011 - 01:05 PM

similar to my edit here http://www.autoitscript.com/forum/topic/131797-windows-and-office-key/page__view__findpost__p__932347

Im afraid Erunt wont help m8 because customers never bring the machines in until it has gone pear shaped and then as we know its tooo late

#30 JFX

JFX

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 11 October 2011 - 05:46 PM

Try this to retrieve key from an offline windows

AutoIt         
    #include <Array.au3>   ;Local Windows ;~ $keys = _DecodeProductKeys()   ;Offline Windows $var = FileSelectFolder("Choose an offline Windows folder.", "") If @error Then Exit   $keys = _DecodeProductKeys($var)   If @error Then MsgBox(16, 'Error', $keys) Else _ArrayDisplay($keys, "Retrieved Windows Keys") EndIf         Func _DecodeProductKeys($Offline = False) Local $Array[9][2], $BinaryDPID, $KeyPos = 0x34 * 2 + 3, $RegKey, $i, $var, $unLoadHive = 0, $OSArch   IF Not $Offline Then $Software = 'SOFTWARE' $OSArch = @OSArch Else IF Not FileExists($Offline & '\system32\config\software') Then Return SetError(1, 0, 'Offline Windows invalid!') IF (ShellExecuteWait('reg', 'load HKLM\_Off_SOFTWARE ' & $Offline & '\system32\config\software', '', '', @SW_HIDE)) = 0 Then $unLoadHive = 1 Else Return SetError(2, 0, 'Could not load Offline Windows registry!') EndIf $Software = '_Off_SOFTWARE' IF FileExists($Offline & '\syswow64\kernel32.dll') Then $OSArch = 'x64' EndIf   $Array[0][0] = 'Windows Key' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion', 'DigitalProductId') $Array[0][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos))     $Array[1][0] = 'Windows Key 4' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion', 'DigitalProductId4') $Array[1][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3))     $Array[2][0] = 'Windows Default' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion\DefaultProductKey', 'DigitalProductId') $Array[2][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos))     $Array[3][0] = 'Windows Default 4' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion\DefaultProductKey', 'DigitalProductId4') $Array[3][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3))       $Array[4][0] = 'Office XP Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\10.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\10.0\Registration' $BinaryDPID = '' 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 $Array[4][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos))     $Array[5][0] = 'Office 2003 Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\11.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\11.0\Registration' $BinaryDPID = '' 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 $Array[5][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos))     $Array[6][0] = 'Office 2007 Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\12.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\12.0\Registration' $BinaryDPID = '' 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 $Array[6][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos))     $Array[7][0] = 'Office 2010 x86 Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\14.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\14.0\Registration' $BinaryDPID = '' 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 $Array[7][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3))     $Array[8][0] = 'Office 2010 x64 Key' $RegKey = 'HKLM64\'& $Software &'\Microsoft\Office\14.0\Registration' IF $OSArch = 'x64' Then $RegKey = '' $BinaryDPID = '' 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 $Array[8][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3))     IF $unLoadHive Then ShellExecuteWait('reg', 'unload HKLM\_Off_SOFTWARE', '', '', @SW_HIDE)   Return $Array   EndFunc       Func _Base24_Decode($BinaryDPID)   Local $bKey[15], $sKey[29], $Digits[24], $Value = 0, $hi = 0, $n = 0, $i = 0, $dlen = 29, $slen = 15, $Result $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")   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   IF $Result = "BBBBB-BBBBB-BBBBB-BBBBB-BBBBB" Then $Result = ""   Return $Result EndFunc      


#31 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 1,520 posts

Posted 12 October 2011 - 12:29 PM

Thanks m8 ill try it at work tommoz and report back

#32 NDog

NDog

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 30 September 2012 - 10:02 AM

I've modified JFX offline version. This is for use in a WINPE environment. If you are using a windows 64 PE environment you must encode this to 64bit. Therefore the Office 2010 detection needed to be slightly modified. Also in some versions of PE FileSelectFolder does not always work properly so I have set it to c:, but someone may want to improve it further.

AutoIt         
 #include ;Local Windows ;~ $keys = _DecodeProductKeys() ;Offline Windows $var = FileSelectFolder("Choose an offline Windows folder.", "C:",4) If @error Then Exit $keys = _DecodeProductKeys($var) If @error Then MsgBox(16, 'Error', $keys) Else _ArrayDisplay($keys, "Retrieved Windows Keys") EndIf Func _DecodeProductKeys($Offline = False) Local $Array[9][2], $BinaryDPID, $KeyPos = 0x34 * 2 + 3, $RegKey, $i, $var, $unLoadHive = 0, $OSArch IF Not $Offline Then $Software = 'SOFTWARE' $OSArch = @OSArch Else IF Not FileExists($Offline & '\system32\config\software') Then Return SetError(1, 0, 'Offline Windows invalid!') IF (ShellExecuteWait('reg', 'load HKLM\_Off_SOFTWARE ' & $Offline & '\system32\config\software', '', '', @SW_HIDE)) = 0 Then $unLoadHive = 1 Else Return SetError(2, 0, 'Could not load Offline Windows registry!') EndIf $Software = '_Off_SOFTWARE' IF FileExists($Offline & '\syswow64\kernel32.dll') Then $OSArch = 'x64' EndIf $Array[0][0] = 'Windows Key' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion', 'DigitalProductId') $Array[0][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos)) $Array[1][0] = 'Windows Key 4' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion', 'DigitalProductId4') $Array[1][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3)) $Array[2][0] = 'Windows Default' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion\DefaultProductKey', 'DigitalProductId') $Array[2][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos)) $Array[3][0] = 'Windows Default 4' $BinaryDPID = RegRead('HKLM64\'& $Software &'\Microsoft\Windows NT\CurrentVersion\DefaultProductKey', 'DigitalProductId4') $Array[3][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3)) $Array[4][0] = 'Office XP Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\10.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\10.0\Registration' $BinaryDPID = '' 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 $Array[4][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos)) $Array[5][0] = 'Office 2003 Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\11.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\11.0\Registration' $BinaryDPID = '' 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 $Array[5][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos)) $Array[6][0] = 'Office 2007 Key' $RegKey = 'HKLM\'& $Software &'\Microsoft\Office\12.0\Registration' IF $OSArch = 'x64' Then $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\12.0\Registration' $BinaryDPID = '' 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 $Array[6][1] = _Base24_Decode(StringMid($BinaryDPID, $KeyPos)) $Array[7][0] = 'Office 2010 HKLM Key' $RegKey = 'HKLM64\'& $Software &'\Microsoft\Office\14.0\Registration' $BinaryDPID = '' 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 $Array[7][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3)) $Array[8][0] = 'Office 2010 HKLM Wow6432Node Key' $RegKey = 'HKLM64\'& $Software &'\Wow6432Node\Microsoft\Office\14.0\Registration' $BinaryDPID = '' 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 $Array[8][1] = _Base24_Decode(StringMid($BinaryDPID, 0x328 * 2 + 3)) IF $unLoadHive Then ShellExecuteWait('reg', 'unload HKLM\_Off_SOFTWARE', '', '', @SW_HIDE) Return $Array EndFunc Func _Base24_Decode($BinaryDPID) Local $bKey[15], $sKey[29], $Digits[24], $Value = 0, $hi = 0, $n = 0, $i = 0, $dlen = 29, $slen = 15, $Result $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "") 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 IF $Result = "BBBBB-BBBBB-BBBBB-BBBBB-BBBBB" Then $Result = "" Return $Result EndFunc


#33 PixelPixPanreyes

PixelPixPanreyes

    Seeker

  • Normal Members
  • 2 posts

Posted 24 December 2012 - 05:31 PM

Hello. Has anyone figured out how to also support Windows 8 key?

I got this VBS code from mydigitallife.info but I don't know how to convert it to AutoIT!
Plain Text         
Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")) Function ConvertToKey(Key)     Const KeyOffset = 52     isWin8 = (Key(66) \ 6) And 1     Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)     i = 24     Chars = "BCDFGHJKMPQRTVWXY2346789"     Do         Cur = 0         X = 14         Do             Cur = Cur * 256             Cur = Key(X + KeyOffset) + Cur             Key(X + KeyOffset) = (Cur \ 24)             Cur = Cur Mod 24             X = X -1         Loop While X >= 0         i = i -1         KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput         Last = Cur     Loop While i >= 0     If (isWin8 = 1) Then         keypart1 = Mid(KeyOutput, 2, Last)         insert = "N"         KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)         If Last = 0 Then KeyOutput = insert & KeyOutput     End If     a = Mid(KeyOutput, 1, 5)     b = Mid(KeyOutput, 6, 5)     c = Mid(KeyOutput, 11, 5)     d = Mid(KeyOutput, 16, 5)     e = Mid(KeyOutput, 21, 5)     ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e End Function


I'm a bad programmer and I should feel bad :)

#34 UEZ

UEZ

    Never say never

  • MVPs
  • 3,605 posts

Posted 24 December 2012 - 09:51 PM

Try this

AutoIt         
;converted by UEZ 2012 MsgBox(0, "Windows Key", "Your " & @OSVersion & " key is : " & GetWindowsProductKey()) Func GetWindowsProductKey()     Local Const $iKeyOffset = 52     Local $sHKLM = "HKLM", $i     If @OSArch = "X64" Then $sHKLM &= "64"     Local $bKey = RegRead($sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")     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     If $isWin8 Then         Local Const $sKeyPart1 = StringMid($sKeyOutput, 2, $iLast)         Local Const $sInsert = "N"         $sKeyOutput = StringReplace(StringTrimLeft($sKeyOutput, 1), $sKeyPart1, $sKeyPart1 & $sInsert, 1)         If Not $iLast Then $sKeyOutput = $sInsert & $sKeyOutput     EndIf     Return StringRegExpReplace($sKeyOutput, '(\w{5})(\w{5})(\w{5})(\w{5})(\w{5})', '\1-\2-\3-\4-\5') ;~  Return StringMid($sKeyOutput, 1, 5) & "-" & _ ;~                  StringMid($sKeyOutput, 6, 5) & "-" & _ ;~                  StringMid($sKeyOutput, 11, 5) & "-" & _ ;~                  StringMid($sKeyOutput, 16, 5) & "-" & _ ;~                  StringMid($sKeyOutput, 21, 5) EndFunc #cs Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")) Function ConvertToKey(Key)     Const KeyOffset = 52     isWin8 = (Key(66) \ 6) And 1     Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)     i = 24     Chars = "BCDFGHJKMPQRTVWXY2346789"     Do         Cur = 0         X = 14         Do             Cur = Cur * 256             Cur = Key(X + KeyOffset) + Cur             Key(X + KeyOffset) = (Cur \ 24)             Cur = Cur Mod 24             X = X -1         Loop While X >= 0         i = i -1         KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput         Last = Cur     Loop While i >= 0     If (isWin8 = 1) Then         keypart1 = Mid(KeyOutput, 2, Last)         insert = "N"         KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)         If Last = 0 Then KeyOutput = insert & KeyOutput     End If     a = Mid(KeyOutput, 1, 5)     b = Mid(KeyOutput, 6, 5)     c = Mid(KeyOutput, 11, 5)     d = Mid(KeyOutput, 16, 5)     e = Mid(KeyOutput, 21, 5)     ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e End Function #ce


and let me know whether it works properly.

Br,
UEZ

Edited by UEZ, 26 December 2012 - 06:59 PM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#35 guinness

guinness

    guinness

  • MVPs
  • 10,347 posts

Posted 24 December 2012 - 09:59 PM

Nice conversion UEZ.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#36 guinness

guinness

    guinness

  • MVPs
  • 10,347 posts

Posted 24 December 2012 - 10:22 PM

Maybe that StringMid return pattern could be replaced with this >>
Return StringRegExpReplace($sKeyOutput, '(\w{5})(\w{5})(\w{5})(\w{5})(\w{5})', '\1-\2-\3-\4-\5')

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#37 UEZ

UEZ

    Never say never

  • MVPs
  • 3,605 posts

Posted 24 December 2012 - 11:20 PM

This was just a flat conversion and thus enough room for optimizations. ;)

Br,
UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#38 PixelPixPanreyes

PixelPixPanreyes

    Seeker

  • Normal Members
  • 2 posts

Posted 25 December 2012 - 12:36 AM

Thanks! It worked perfectly! :D

#39 supersonic

supersonic

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 448 posts

Posted 07 January 2013 - 10:42 AM

@ UEZ:

Thank you for the conversion! :-)

The code seems to work properly for Windows Server 2012 / 8 only?

Can it be modified to work for all 'DigitalProductId' values?

#40 JFX

JFX

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 08 January 2013 - 09:24 PM

@ UEZ:

Thank you for the conversion! :-)

The code seems to work properly for Windows Server 2012 / 8 only?

Can it be modified to work for all 'DigitalProductId' values?


I've updated the script one 1 post, using UEZ's conversion.

Should now work on all Windows versions, but have not checked yet.

Edited by JFX, 08 January 2013 - 09:24 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users