Code: Select all
Set WshShell = CreateObject("WScript.Shell")
wscript.echo ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ConvertToKey = KeyOutput
End Function
It would be great to have a .cmd that would display product key for Windows and Office from XP and up (have to search for info how to distinguish this).
Saso
Did some search:
https://answers.microsoft.com/en-us/win ... 3db2f6ae11
https://answers.microsoft.com/en-us/win ... h=1&page=4:
Note mentioned above:
Code: Select all
You may need to change the code to DigitalProductId4 if it is 64 bits, that's what I had to do.