Check Windows 7 Activation Using VBS

So i had some issues trying to use windows activation and wanted to be able to report on the OS status using BGInfo.

My below script can be referenced  inside BGInfo.

I might be worth downloading WMI Code Creator v1.0 This can be used to show what other information is ready for the picking.

Editing the below script will be able to report on any of the records WMI can throw your way.


Copy and paste the following code into a new .vbs file

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From SoftwareLicensingProduct")
Coltest = int(0)
IsWinActivated = True

For Each objitem In colItems
IF int(objitem.GracePeriodRemaining) = 0 Then Coltest = True else Coltest = False
IF Coltest = False then IsWinActivated = False

IF IsWinActivated = False then
call echo "Failed"
call echo "Successful"

Print Friendly, PDF & Email
  • Trackback are closed
  • Comments (4)
    • Bob
    • November 9th, 2011

    Nice script

    • Kyle Wadman
    • November 9th, 2011


    • ThomasBoomer
    • April 4th, 2013

    You are using the wrong method for checking activation status. If you use a MAK key to activate and check GracePeriodRemaining it will be zero.

    The correct method to use is LicenseStatus. A value of 1 means activated. The following code is better:

    Set objWMIService = GetObject(“winmgmts:\\.\root\cimv2”)
    Set colItems = objWMIService.ExecQuery(“Select * From SoftwareLicensingProduct”)
    Coltest = int(0)
    bWinActivated = False

    For Each objitem In colItems
    WScript.Echo objItem.Description
    WScript.Echo “License Status: “& objitem.LicenseStatus
    WScript.Echo objitem.GracePeriodRemaining
    WScript.Echo “KeyManagementServiceProductKeyID: “&objitem.KeyManagementServiceProductKeyID
    IF int(objitem.LicenseStatus) 0 Then

    bWinActivated = True
    strActivationType = objItem.Description
    strKey = “ProductKey:” & objItem.ProductKeyID

    End if
    If bWinActivated = False Then MsgBox(“Windows is not activated”)
    If bWinActivated = True Then
    MsgBox(“Windows is activated using “&strActivationType& ” key.” & strKey)
    End if

    • Kyle Wadman
    • April 7th, 2013

    Thank you for your comment. I will test and if so, replace my post. Including credit 🙂

Warning: Use of undefined constant cs_print_smilies - assumed 'cs_print_smilies' (this will throw an Error in a future version of PHP) in D:\Domains\\wwwroot\blog\wp-content\themes\monochrome\comments.php on line 185