Advertisement
Guest User

Get your product key back

a guest
Mar 19th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Option Explicit  
  4.  
  5. Dim objshell,path,DigitalID, Result  
  6. Set objshell = CreateObject("WScript.Shell")
  7. 'Set registry key path
  8. Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
  9. 'Registry key value
  10. DigitalID = objshell.RegRead(Path & "DigitalProductId")
  11. Dim ProductName,ProductID,ProductKey,ProductData
  12. 'Get ProductName, ProductID, ProductKey
  13. ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
  14. ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
  15. ProductKey = "Installed Key: " & ConvertToKey(DigitalID)  
  16. ProductData = ProductName  & vbNewLine & ProductID  & vbNewLine & ProductKey
  17. 'Show messbox if save to a file  
  18. If vbYes = MsgBox(ProductData  & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then
  19.    Save ProductData  
  20. End If
  21.  
  22.  
  23.  
  24. 'Convert binary to chars
  25. Function ConvertToKey(Key)
  26.     Const KeyOffset = 52
  27.     Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
  28.     'Check if OS is Windows 8
  29.    isWin8 = (Key(66) \ 6) And 1
  30.     Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
  31.     i = 24
  32.     Maps = "BCDFGHJKMPQRTVWXY2346789"
  33.     Do
  34.            Current= 0
  35.         j = 14
  36.         Do
  37.            Current = Current* 256
  38.            Current = Key(j + KeyOffset) + Current
  39.            Key(j + KeyOffset) = (Current \ 24)
  40.            Current=Current Mod 24
  41.             j = j -1
  42.         Loop While j >= 0
  43.         i = i -1
  44.         KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
  45.         Last = Current
  46.     Loop While i >= 0  
  47.      
  48.     If (isWin8 = 1) Then
  49.         keypart1 = Mid(KeyOutput, 2, Last)
  50.         insert = "N"
  51.         KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
  52.         If Last = 0 Then KeyOutput = insert & KeyOutput
  53.     End If    
  54.      
  55.  
  56.     ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)
  57.    
  58.      
  59. End Function
  60. 'Save data to a file
  61. Function Save(Data)
  62.     Dim fso, fName, txt,objshell,UserName
  63.     Set objshell = CreateObject("wscript.shell")
  64.     'Get current user name  
  65.    UserName = objshell.ExpandEnvironmentStrings("%UserName%")  
  66.     'Create a text file on desktop  
  67.    fName = "C:\Users\" & UserName & "\Desktop\WindowsKeyInfo.txt"
  68.     Set fso = CreateObject("Scripting.FileSystemObject")
  69.     Set txt = fso.CreateTextFile(fName)
  70.     txt.Writeline Data
  71.     txt.Close
  72. End Function
  73.  
  74. MsgBox("Consider subscribing to geekout. Document saved to desktop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement