Opção explícita
Dim objshell, caminho, ID digital, resultado
Definir objshell = CreateObject (“WScript.Shell”)
‘Definir caminho da chave do Registro
Caminho = “HKLM SOFTWARE Microsoft Windows CurrentVersion ”
Valor da chave do registro
DigitalID = objshell.RegRead (caminho & “DigitalProductId”)
Dim ProductName, ProductID, ProductKey, ProductData
‘Get ProductName, ProductID, ProductKey
ProductName = “Nome do produto:” & objshell.RegRead (Caminho e “ProductName”)
ProductID = “ID do produto:” & objshell.RegRead (Path & “ProductID”)
ProductKey = “Chave Instalada:” & ConvertToKey (DigitalID)
ProductData = ProductName & vbNewLine & ProductID & vbNewLine & ProductKey
‘Mostrar a caixa de mensagens se salvar em um arquivo
Se vbYes = MsgBox (ProductData & vblf & vblf & “Salvar em um arquivo?”, VbYesNo + vbQuestion, “Fazer backup das informações principais do Windows”),
Salvar dados do produto
Fim se
‘Converter binário em caracteres
Função ConvertToKey (Key)
Const KeyOffset = 52
Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
‘Verifique se o SO é Windows 8
isWin8 = (Chave (66) 6) E 1
Chave (66) = (Chave (66) E & HF7) Ou ((isWin8 E 2) * 4)
i = 24
Maps = “BCDFGHJKMPQRTVWXY2346789”
Faz
Atual = 0
j = 14
Faz
Atual = Atual * 256
Atual = Chave (j + KeyOffset) + Atual
Chave (j + KeyOffset) = (Atual 24)
Atual = Mod atual 24
j = j -1
Loop Enquanto j> = 0
i = i -1
KeyOutput = Mid (Maps, Current + 1, 1) e KeyOutput
Último = Atual
Loop Enquanto i> = 0
Se (isWin8 = 1) Então
keypart1 = Mid (KeyOutput, 2, Last)
inserir = “N”
KeyOutput = Replace (KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then KeyOutput = insert & KeyOutput
Fim se
ConvertToKey = Mid (KeyOutput, 1, 5) & “-” & Mid (KeyOutput, 6, 5) & “-” & Mid (KeyOutput, 11, 5) & “-” & Mid (KeyOutput, 16, 5) e “-” & Médio (KeyOutput, 21, 5)
Função final
‘Salvar dados em um arquivo
Função Salvar (Dados)
Dim fso, fName, txt, objshell, UserName
Defina objshell = CreateObject (“wscript.shell”)
‘Obter nome de usuário atual
UserName = objshell.ExpandEnvironmentStrings (“% UserName%”)
‘Crie um arquivo de texto na área de trabalho
fName = “C: Users ” & UserName & ” Desktop WindowsKeyInfo.txt”
Defina fso = CreateObject (“Scripting.FileSystemObject”)
Defina txt = fso.CreateTextFile (fName)
txt.Writeline Data
txt.Close
Função final