ulvis.paste.net

Paste Search Dynamic
Recent pastes
GetProductKey.vbs
  1. Option Explicit  
  2.  
  3. Dim objshell,path,DigitalID, Result  
  4. Set objshell = createobject("WScript.Shell")
  5. 'Set registry key path
  6. Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
  7. 'Registry key value
  8. DigitalID = objshell.RegRead(Path & "DigitalProductId")
  9. Dim ProductName,ProductID,ProductKey,ProductData
  10. 'Get ProductName, ProductID, ProductKey
  11. ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
  12. ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
  13. ProductKey = "Installed Key: " & ConvertToKey(DigitalID)  
  14. ProductData = ProductName  & vbNewLine & ProductID  & vbNewLine & ProductKey
  15. 'Show messbox if save to a file  
  16. if vbYes = MsgBox(ProductData  & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then
  17.    save ProductData  
  18. end if
  19.  
  20.  
  21.  
  22. 'Convert binary to chars
  23. Function ConvertToKey(Key)
  24.    Const KeyOffset = 52
  25.    Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
  26.    'check if OS is Windows 8
  27.     isWin8 = (Key(66) \ 6) And 1
  28.     Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
  29.     i = 24
  30.     Maps = "BCDFGHJKMPQRTVWXY2346789"
  31.     Do
  32.            Current= 0
  33.         j = 14
  34.         Do
  35.            Current = Current* 256
  36.            Current = Key(j + KeyOffset) + Current
  37.            Key(j + KeyOffset) = (Current \ 24)
  38.            Current=Current mod 24
  39.             j = j -1
  40.         Loop while j >= 0
  41.         i = i -1
  42.         KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
  43.         Last = Current
  44.     Loop while i >= 0  
  45.      
  46.     if (isWin8 = 1) then
  47.         keypart1 = Mid(KeyOutput, 2, Last)
  48.         insert = "N"
  49.         KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
  50.         if Last = 0 then KeyOutput = insert & KeyOutput
  51.     end if    
  52.      
Parsed in 0.028 seconds