adamchilcott

getKey.vbs

Nov 1st, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set WshShell = CreateObject("WScript.Shell")
  2. MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
  3.  
  4. Function ConvertToKey(Key)
  5. Const KeyOffset = 52
  6. i = 28
  7. Chars = "BCDFGHJKMPQRTVWXY2346789"
  8. Do
  9. Cur = 0
  10. x = 14
  11. Do
  12. Cur = Cur * 256
  13. Cur = Key(x + KeyOffset) + Cur
  14. Key(x + KeyOffset) = (Cur \ 24) And 255
  15. Cur = Cur Mod 24
  16. x = x -1
  17. Loop While x >= 0
  18. i = i -1
  19. KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
  20. If (((29 - i) Mod 6) = 0) And (i <> -1) Then
  21. i = i -1
  22. KeyOutput = "-" & KeyOutput
  23. End If
  24. Loop While i >= 0
  25. ConvertToKey = KeyOutput
  26. End Function
Add Comment
Please, Sign In to add comment