zoukankan      html  css  js  c++  java
  • AU3获取系统激活信息

    If IsActivated() = False Then
       ;InstallProductKey($OSkey) ; installs a product key and also activates it
      Else
       MsgBox(0,'','ssssss os')
      EndIf
    
     If OfficeIsActivated() = False Then
      ;InstallOfficeProductKey($officekey) ; installs a product key and also activates it
     Else
     MsgBox(0,'','ssssss offf')
     EndIf
    
    Func IsActivated()
     $oWMIService = ObjGet("winmgmts:\.
    ootcimv2")
     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)
          Return False
         Case 1
          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 2
          ConsoleWrite("Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 3
          ConsoleWrite("Additional grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 4
          ConsoleWrite("Non-genuine grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 5
          ConsoleWrite("Windows is in Notification mode" & @CRLF)
          Return False
         Case 6
          ConsoleWrite("Extended grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
        EndSwitch
       Next
      EndIf
     EndIf
    EndFunc
    
    Func OfficeIsActivated()
     $oWMIService = ObjGet("winmgmts:\.
    ootcimv2")
     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 0
          ConsoleWrite(" ---UNLICENSED--- " & @CRLF)
          Return False
         Case 1
          ConsoleWrite(" ---LICENSED--- " & @CRLF)
           ;If licSr = 0 Then
           ; WScript.Echo MSG_ERRCODE & licSr & " as licensed"
           ;End If
          Return True
         Case 2
          ConsoleWrite("---OOB_GRACE--- Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 3
          ConsoleWrite("---OOT_GRACE--- Initial grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 4
          ConsoleWrite("---NON_GENUINE_GRACE--- Grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 5
          ConsoleWrite("---NOTIFICATIONS--- Grace period ends in " & $oItem.GracePeriodRemaining & " minutes" & @CRLF)
          Return False
         Case 6
          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
    版权声明:本博客所有图片、文字等版权属于虫子樱桃所有,未经许可谢绝任何形式的复制和传播。博客的图片和代码部分来自网络,本站均已注明来源和作者原来的声明。如有侵权,请使用本站联系方式告诉,我们将会在第一时间做出处理。
  • 相关阅读:
    [iOS基础控件
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    [iOS 多线程 & 网络
    linux开发脚本自动部署及监控
  • 原文地址:https://www.cnblogs.com/czytcn/p/7645597.html
Copyright © 2011-2022 走看看