KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Extracting windows license key

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
lowbug



Joined: 01 Mar 2012
Posts: 10

PostPosted: Sun Dec 01, 2019 5:41 am    Post subject: Extracting windows license key Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Sun Dec 01, 2019 7:57 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
lowbug



Joined: 01 Mar 2012
Posts: 10

PostPosted: Sun Dec 01, 2019 1:12 pm    Post subject: Reply with quote

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

I guess we cant do it.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Sun Dec 01, 2019 2:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index