码迷,mamicode.com
首页 > 其他好文 > 详细

AU3获取系统激活信息

时间:2017-10-10 16:27:00      阅读:580      评论:0      收藏:0      [点我收藏+]

标签:ati   man   unknown   class   console   software   cccccc   round   rem   

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:\\.\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 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:\\.\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 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

AU3获取系统激活信息

标签:ati   man   unknown   class   console   software   cccccc   round   rem   

原文地址:http://www.cnblogs.com/czytcn/p/7645597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!