Extracting windows license key

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
lowbug
Posts: 10
Joined: Thu Mar 01, 2012 5:02 am

Extracting windows license key

Post by lowbug »

Hi,

I am running a test using a script to pull the windows key. I know the test works with an OK result but it doesn't appear to provide the key output?

Set WshShell = CreateObject("WScript.Shell")
Set shell = CreateObject("WScript.Shell")
Set getOSName = shell.exec("%comspec% /c wmic os get Caption /value")

MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
version = getOSName.stdout.readall
wscript.echo version
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
Wscript.Echo ConvertToKey
wscript.quit
End Function

Any ideas?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Are you using Shell Script test method? Then please check the manual related to this test
https://www.ks-soft.net/hostmon.eng/mfr ... m#shellres

The script or external program must write to stdout (standard output stream) single result string. This string should contain 3 parts separated by colon (:).

First obligatory part - marker "scriptres" tells to HostMonitor or RMA that this string is the result string.

Second obligatory part represents the test status, it can take one of the following values (case insensitive):

Third optional part contains Reply value (windows key in your case).
So you missed part 1 and part 2

Regards
Alex
lowbug
Posts: 10
Joined: Thu Mar 01, 2012 5:02 am

Post by lowbug »

Sorry, I'm confused. I don't know VB that well tbh :(

I guess we cant do it. :oops:
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You need to modify 2 lines
1) remove MsgBox
2) change Wscript.Echo ConvertToKey to something like Wscript.Echo "scriptres:Ok:"&ConvertToKey

Regards
Alex
Post Reply