среда, 24 сентября 2014 г.

VBScript: просмотр лицензионного ключа Windows

Данный скрипт позволит увидеть введённый при установке системы лицензионный ключ Windows:

SET WshShell = CreateObject("WScript.Shell")
regKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
DigitalProductId = WshShell.RegRead(regKey & "DigitalProductId")
WinProductName = "Windows Product Name: " & WshShell.RegRead(regKey & "ProductName") & vbNewLine
WinProductID = "Windows Product ID: " & WshShell.RegRead(regKey & "ProductID") & vbNewLine
WinProductKey = ConvertToKey(DigitalProductId)
strProductKey ="Windows Product Key: " & WinProductKey
WinProductID = WinProductName & WinProductID & strProductKey
MsgBox(WinProductID)

FUNCTION ConvertToKey(regKey)
 Const KeyOffset = 52
 isWin8 = (regKey(66) \ 6) And 1
 regKey(66) = (regKey(66) And &HF7) Or ((isWin8 And 2) * 4)
 j = 24
 Chars = "BCDFGHJKMPQRTVWXY2346789"
 DO
  Cur = 0
  y = 14
  DO
   Cur = Cur * 256
   Cur = regKey(y + KeyOffset) + Cur
   regKey(y + KeyOffset) = (Cur \ 24)
   Cur = Cur Mod 24
   y = y -1
  LOOP WHILE y >= 0
  j = j -1
  winKeyOutput = Mid(Chars, Cur + 1, 1) & winKeyOutput
  Last = Cur
 LOOP WHILE j >= 0
 IF (isWin8 = 1) THEN
  keypart1 = Mid(winKeyOutput, 2, Last)
  insert = "N"
  winKeyOutput = Replace(winKeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
  IF Last = 0 THEN winKeyOutput = insert & winKeyOutput
 END IF
 a = Mid(winKeyOutput, 1, 5)
 b = Mid(winKeyOutput, 6, 5)
 c = Mid(winKeyOutput, 11, 5)
 d = Mid(winKeyOutput, 16, 5)
 e = Mid(winKeyOutput, 21, 5)
 ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e
END FUNCTION

Комментариев нет:

Отправить комментарий