你弄个函数就行了啊
Local $sProductID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ;产品ID
Activate($sProductID)
If Not @error Then
MsgBox(512, '', '成功')
Else
MsgBox(16, '', '失败')
EndIf
Func Activate($sProductID)
Local $colServices = ObjGet("winmgmts:").ExecQuery("SELECT Version FROM SoftwareLicensingService")
For $objProduct In ObjGet("winmgmts:").ExecQuery("SELECT ID FROM SoftwareLicensingProduct where id = '" & $sProductID & "'")
$objProduct.Activate()
For $objService In $colServices
$objService.RefreshLicenseStatus()
Next
$objProduct.refresh_
Return True
Next
Return SetError(1, 0, False)
EndFunc ;==>Activate
|