Run with cscript.exe
cscript script.vbs
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 Next If bWinActivated = False Then MsgBox("Windows is not activated") If bWinActivated = True Then MsgBox("Windows is activated using "&strActivationType& " key." & strKey) End if
Notes
slmgr /dli