gromito Posted November 5, 2010 Share Posted November 5, 2010 Hi to all, a short question. I need that a variable contains 0 if windows is activated and 1 if it is not. I can call from autoit the vbs from ms slmgr.vbs /xpr that gives me the correct answer, but I need it in a var to include it in my script, without the msgbox popup. Can someone help me in this? Thanks all for your help. Have a nice Weekend! Gianluca Link to comment Share on other sites More sharing options...
JFX Posted November 5, 2010 Share Posted November 5, 2010 Well not a good solution, but maybe useful #RequireAdmin $STDOUT = '' FileCopy(@SystemDir & '\slmgr.vbs', @TempDir) ; Copy to temp --> No MUI $PID = Run(@ComSpec & ' /c @echo off && for /f "tokens=* skip=4" %i in ' _ & "('cscript " & '"%Temp%\slmgr.vbs"' & " /xpr')" _ & "do echo %i", '', @SW_HIDE , 2) ;$STDOUT_CHILD While 1 $STDOUT &= StdoutRead($PID) If @error Then ExitLoop WEnd ConsoleWrite($STDOUT) Link to comment Share on other sites More sharing options...
gromito Posted November 8, 2010 Author Share Posted November 8, 2010 Perfect it is doing the thing I need! and I learned another AutoIT trick Gianluca Link to comment Share on other sites More sharing options...
trancexx Posted November 15, 2010 Share Posted November 15, 2010 (edited) I stumbled upon this yesterday. ...Just to say that more proper way would be to do it like this (slmgr.vbs is known to be tempered, so they say): $oWMIService = ObjGet("winmgmts:\\.\root\cimv2") If IsObj($oWMIService) Then $oCollection = $oWMIService.ExecQuery("SELECT Description, LicenseStatus, GracePeriodRemaining FROM SoftwareLicensingProduct WHERE PartialProductKey <> null") If IsObj($oCollection) Then For $oItem In $oCollection Switch $oItem.LicenseStatus Case 0 ConsoleWrite("Unlicensed" & @CRLF) Case 1 If $oItem.GracePeriodRemaining Then If StringInStr($oItem.Description, "TIMEBASED_") Then ConsoleWrite("Timebased activation will expire in" & $oItem.GracePeriodRemaining & " minutes" & @CRLF) Else ConsoleWrite("Volume activation will expire in" & $oItem.GracePeriodRemaining & " minutes" & @CRLF) EndIf Else ConsoleWrite("The machine is permanently activated." & @CRLF) EndIf Case 2 ConsoleWrite("Initial grace period ends in" & $oItem.GracePeriodRemaining & " minutes" & @CRLF) Case 3 ConsoleWrite("Additional grace period ends in" & $oItem.GracePeriodRemaining & " minutes" & @CRLF) Case 4 ConsoleWrite("Non-genuine grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF) Case 5 ConsoleWrite("Windows is in Notification mode" & @CRLF) Case 6 ConsoleWrite("Extended grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF) EndSwitch Next EndIf EndIf Edited November 15, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JFX Posted November 15, 2010 Share Posted November 15, 2010 very good, this much better. thanks a lot trancexx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now