Sign in to follow this  
Followers 0
gromito

Want to know if Win7 is activated

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

Perfect it is doing the thing I need! and I learned another AutoIT trick :graduated:

Gianluca

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

very good, this much better.

thanks a lot trancexx

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0