#208106 - 2013-12-01 10:03 PM
Re: Cd Key lookup.
[Re: Lonkero]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
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.
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
|
|
|
|
#211260 - 2016-04-02 10:42 PM
Re: Cd Key lookup.
[Re: BillBarnard]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
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.
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 307 anonymous users online.
|
|
|