If IsActivated() = False Then
;InstallProductKey($OSkey) ; installs a product key and also activates it
Else
MsgBox(,'','ssssss os')
EndIf If OfficeIsActivated() = False Then
;InstallOfficeProductKey($officekey) ; installs a product key and also activates it
Else
MsgBox(,'','ssssss offf')
EndIf Func IsActivated()
$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
ConsoleWrite("Unlicensed" & @CRLF)
Return False
Case
If $oItem.GracePeriodRemaining Then
If StringInStr($oItem.Description, "TIMEBASED_") Then
ConsoleWrite("Timebased activation will expire in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Else
ConsoleWrite("Volume activation will expire in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
EndIf
Else
ConsoleWrite("The machine is permanently activated." & @CRLF)
Return True
EndIf
Case
ConsoleWrite("Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("Additional grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("Non-genuine grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("Windows is in Notification mode" & @CRLF)
Return False
Case
ConsoleWrite("Extended grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
EndSwitch
Next
EndIf
EndIf
EndFunc Func OfficeIsActivated()
$oWMIService = ObjGet("winmgmts:\\.\root\cimv2")
If IsObj($oWMIService) Then
$oCollection = $oWMIService.ExecQuery("SELECT Description, LicenseStatus, GracePeriodRemaining FROM OfficeSoftwareProtectionProduct WHERE PartialProductKey <> null")
If IsObj($oCollection) Then
For $oItem In $oCollection
Switch $oItem.LicenseStatus
Case
ConsoleWrite(" ---UNLICENSED--- " & @CRLF)
Return False
Case
ConsoleWrite(" ---LICENSED--- " & @CRLF)
;If licSr = Then
; WScript.Echo MSG_ERRCODE & licSr & " as licensed"
;End If
Return True
Case
ConsoleWrite("---OOB_GRACE--- Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("---OOT_GRACE--- Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("---NON_GENUINE_GRACE--- Grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("---NOTIFICATIONS--- Grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case
ConsoleWrite("---EXTENDED GRACE--- Extended grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
Return False
Case Else
ConsoleWrite("---UNKNOWN---" & @CRLF)
Return False
EndSwitch
Next
EndIf
EndIf
EndFunc
05-04 12:23