Jump to content

Want to know if Win7 is activated


gromito
 Share

Recommended Posts

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

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

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...