Page 3 of 3 <123
Topic Options
#201741 - 2011-03-13 07:55 AM Re: Cd Key lookup. [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11559
Loc: CA
Thanks Allen,

I don't have 2010 on here at the moment but if I remember I'll check it out when I do put it on.

Top
#206800 - 2013-02-25 11:33 PM Re: Cd Key lookup. [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
dont work for win7 64bit.
if someone has more free time than I, could looky at:
http://www.vbforums.com/showthread.php?622160-RESOLVED-DigitalProductId-VB-2010-on-Win7-x64

otherwise I need to come back and take a crack at it.
the original code returns BBBBBBBBBBBBBBBBBB and allen's version returns nothing.
_________________________
!

download KiXnet

Top
#206801 - 2013-02-25 11:34 PM Re: Cd Key lookup. [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4396
Loc: USA
What version of Office. I've used this repeatedly with XP, Vista, Win7 32bit or 64bit.

Edit... just saw you say Win7 64 itself.... ah... not sure about that...

Top
#206802 - 2013-02-26 06:39 AM Re: Cd Key lookup. [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
yea, works with winXP. but I need win7 \:\)
_________________________
!

download KiXnet

Top
#206803 - 2013-02-26 03:26 PM Re: Cd Key lookup. [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
it seems to work on win7 too now... at least for some.
that is odd.
_________________________
!

download KiXnet

Top
#208095 - 2013-11-29 06:05 PM Re: Cd Key lookup. [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4396
Loc: USA
FYI... I have not had time to hunt down the info on how it has changed, but I know that none of the versions posted above work with Office 2013 or Windows 8.
Top
#208097 - 2013-11-29 06:20 PM Re: Cd Key lookup. [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
windows 8?
is someone already using it?

/sent from my home vista laptop/
_________________________
!

download KiXnet

Top
#208106 - 2013-12-01 10:03 PM Re: Cd Key lookup. [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4396
Loc: USA
If anyone want to take a stab at merging this with the versions above, here is a vbscript that gets the Windows 8 product key. I have yet to find any information on how to get Office 2013 keys.

 Code:
Option Explicit 

Dim strComputer, objWMIService, objItem, Caption, colItems
'Create wscript.shell object 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    Caption = objItem.Caption  
Next

If InStr(Caption,"Microsoft Windows 8") > 0  Then 
	Dim objshell,path,DigitalID, Result 
	Set objshell = CreateObject("WScript.Shell")
	'Set registry key path
	Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
	'Registry key value
	DigitalID = objshell.RegRead(Path & "DigitalProductId")
	Dim ProductName,ProductID,ProductKey,ProductData
	'Get ProductName, ProductID, ProductKey
	ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
	ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
	ProductKey = "Installed Key: " & ConvertToKey(DigitalID) 
	ProductData = ProductName  & vbNewLine & ProductID  & vbNewLine & ProductKey
	'Show messbox if save to a file 
	If vbYes = MsgBox(ProductData  & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then
	   Save ProductData 
	End If
 
Else
	MsgBox "Please run this script in Windows 8.x"	
End If 


'Convert binary to chars
Function ConvertToKey(Key)
    Const KeyOffset = 52
    Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
    'Check if OS is Windows 8
    isWin8 = (Key(66) \ 6) And 1
    Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
    i = 24
    Maps = "BCDFGHJKMPQRTVWXY2346789"
    Do
       	Current= 0
        j = 14
        Do
           Current = Current* 256
           Current = Key(j + KeyOffset) + Current
           Key(j + KeyOffset) = (Current \ 24)
           Current=Current Mod 24
            j = j -1
        Loop While j >= 0
        i = i -1
        KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
        Last = Current
    Loop While i >= 0 
    keypart1 = Mid(KeyOutput, 2, Last)
    insert = "N"
    KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
    If Last = 0 Then KeyOutput = insert & KeyOutput
    ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)
   
    
End Function
'Save data to a file
Function Save(Data)
    Dim fso, fName, txt,objshell,UserName
    Set objshell = CreateObject("wscript.shell")
    'Get current user name 
    UserName = objshell.ExpandEnvironmentStrings("%UserName%") 
    'Create a text file on desktop 
    fName = "C:\Users\" & UserName & "\Desktop\WindowsKeyInfo.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txt = fso.CreateTextFile(fName)
    txt.Writeline Data
    txt.Close
End Function


Top
#208107 - 2013-12-02 01:10 AM Re: Cd Key lookup. [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
to me the only thing that seems to be valuable from that code are these two lines:
 Code:
    isWin8 = (Key(66) \ 6) And 1
    Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)


so, the last bit is mingled with if windows 8 is the OS.
otherwise the code is exactly the same?
_________________________
!

download KiXnet

Top
#211259 - 2016-04-01 02:26 PM Re: Cd Key lookup. [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Are we certain that the above VB code works?
I have tried it on Windows 10 32-bit and 64-bit and got varying results.
I assume 10 is not that different from 8 as far as the DigitalProductID is concerned.

@dos on Win 10 now gives a value of 10.0, when Win 10 first came out it was 6.2, the same as Win 8.x (I think, as I never got into 8).
Cheers,
_________________________
Bill

Top
#211260 - 2016-04-02 10:42 PM Re: Cd Key lookup. [Re: BillBarnard]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1850
Loc: Hilversum, The Netherlands
I wrote a keyfinder a long(!) time ago in KixForms (the non-.net version) based on some of Lonk's code. Might be of some help.

 Code:
Break On
$System = CreateObject("Kixtart.System")

;KD START

$Form = $System.Form()
$Form.BackColor = 235,233,237
$Form.FontSize = 8,25
$Form.Height = 255
$Form.Text = "KeyFinder"
$Form.Width = 455
$Button1 = $Form.Controls.Button()
$Button1.FontSize = 8,25
$Button1.Height = 33
$Button1.Left = 15
$Button1.Text = "Exit"
$Button1.Top = 165
$Button1.Width = 420
$Button1.OnClick = "$$=$$Form.Hide()"
$ListViewEx1 = $Form.Controls.ListView()
$ListViewEx1.FontSize = 8,25
$ListViewEx1.Height = 134
$ListViewEx1.Left = 15
$ListViewEx1.Top = 15
$ListViewEx1.Width = 420
$=$ListViewEx1.Columns.Add("Product",200)
$=$ListViewEx1.Columns.Add("Key Code",215)

;KD END

$Form.Show
StartScript
While $Form.Visible
   $=Execute($Form.DoEvents())
Loop
Exit 1

Function StartScript()
  $Form.Text = "KeyFinder - SEARCHING!!!!"
  $ListViewEx1.Items.Clear
  $ListViewEx1.Enabled = 0
  $ListViewEx1.BeginUpdate
  Dim $RegArray,$Value,$Product,$Key
  $RegArray = SearchReg("HKLM\Software\Microsoft","DigitalProductID",2)
  If @Error
  'No matching items found' ?
  Else
    For Each $Value In $RegArray
      If $Value
        $Product = ReadValue(Join(Split($value,'<=>DigitalProductId'),''),'ProductName')
        If $Product
          $Key = Get_Product_Key(ReadValue(Join(Split($value,'<=>DigitalProductId'),''), 'DigitalProductID'))
          $Item = $ListViewEx1.Items.Add($Product)
          $Item.SubItems(1).Text = $Key
;         $Product + ': ' + $Key ?
        EndIf
      EndIf
    Next
  EndIf
  $ListViewEx1.EndUpdate
  $ListViewEx1.Enabled = 1
  $Form.Text = "KeyFinder - Finished!"
EndFunction
  
Function SearchReg($Key,$Str,$SrcIn)
  Dim $Idx,$vName,$Value,$num,$SubKey,$fArr,$mbr
  $SearchReg = ''
  $num = 0
  $Idx = 0
  $vName = EnumValue($Key,$Idx)
  Do
    $mbr = ''
    If $SrcIn & 1
    $Value = ReadValue($Key,$vName)
     If InStr($Value,$Str)
       $mbr = $Key + "<=>" + IIf($vName,$vName,'<Default>')
     EndIf
    EndIf
    If ($SrcIn & 2) AND InStr($vName,$Str)
      $mbr = $Key + "<=>" + $vName
    EndIf
    If $mbr
      ReDim Preserve $SearchReg[$num]
      $SearchReg[$num] = $mbr
      $num = $num + 1
    EndIf
    $Idx = $Idx + 1
    $vName = EnumValue($Key,$Idx)
  Until @Error
  $Idx = 0
  $SubKey = EnumKey($Key,$Idx)
  While $SubKey
    If ($SrcIn & 4) AND InStr($SubKey,$Str)
      ReDim Preserve $SearchReg[$num]
      $SearchReg[$num] = $Key + '\' + $SubKey + "<=><KeyName>"
      $num = $num + 1
    EndIf
    $fArr = SearchReg($Key + "\" + $SubKey,$Str,$SrcIn)
    If @Error = 0
      For Each $mbr In $fArr
        ReDim Preserve $SearchReg[$num]
        $SearchReg[$num] = $mbr
        $num = $num + 1
      Next
    EndIf
    $Idx = $Idx + 1
    $SubKey = EnumKey($Key,$Idx)
  Loop
  Exit VarType($SearchReg) = 8
EndFunction
  
Function Get_Product_Key($sProductID)
  Dim $aiKeyChars[24],$bProductKey[15],$ilByte,$i,$sCDKey,$nCur
  $aiKeyChars = Split('B,C,D,F,G,H,J,K,M,P,Q,R,T,V,W,X,Y,2,3,4,6,7,8,9',',')
  For $i = 0 To 14
    $bProductKey[$i] = Val("&"+SubStr($sProductID,$i*2+105,2))
  Next
  $sCDKey = ""
  For $ilByte = 24 To 0 Step -1
    $nCur = 0
    For $i=14 To 0 Step -1
      $nCur = $nCur * 256 | $bProductKey[$i]
      $bProductKey[$i] = Int($nCur / 24)
      $nCur = $nCur Mod 24
    Next
    $sCDKey = $aiKeyChars[$nCur] + $sCDKey
    If $ilByte Mod 5 = 0 AND $ilByte <> 0 $sCDKey = "-" + $sCDKey EndIf
  Next
  $Get_Product_Key = $sCDKey
EndFunction

Top
#211267 - 2016-04-06 04:11 PM Re: Cd Key lookup. [Re: Arend_]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks Arend_ I'll try it out.
Cheers,
_________________________
Bill

Top
Page 3 of 3 <123


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (KevinOfOz) and 155 anonymous users online.
Newest Members
phanhuyen345, msmile032, bellamabel2018, lmnopq098068, nathanjame
17561 Registered Users

Generated in 0.036 seconds in which 0.012 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org