View previous topic :: View next topic |
Author |
Message |
lowbug
Joined: 01 Mar 2012 Posts: 10
|
Posted: Sun Dec 01, 2019 5:41 am Post subject: Extracting windows license key |
|
|
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? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Sun Dec 01, 2019 7:57 am Post subject: |
|
|
Are you using Shell Script test method? Then please check the manual related to this test
https://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#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 |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
lowbug
Joined: 01 Mar 2012 Posts: 10
|
Posted: Sun Dec 01, 2019 1:12 pm Post subject: |
|
|
Sorry, I'm confused. I don't know VB that well tbh
I guess we cant do it. ![](images/smiles/icon_redface.gif) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Sun Dec 01, 2019 2:41 pm Post subject: |
|
|
You need to modify 2 lines
1) remove MsgBox
2) change Wscript.Echo ConvertToKey to something like Wscript.Echo "scriptres:Ok:"&ConvertToKey
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|