如何使用WMI枚举所有ActiveX元素?

时间:2022-05-02 23:21:53

Is it possible to enumerate all (or just enabled) ActiveX elements (*.dll, *.ocx) with WMI script?

是否可以使用WMI脚本枚举所有(或仅启用)ActiveX元素(* .dll,* .ocx)?

Motivation: ActiveXHelper

1 个解决方案

#1


Scritomatic V2 tool have some sample like that :

Scritomatic V2工具有一些样本:


On Error Resume Next

Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20

Const wbemFlagReturnImmediately =&h10 Const wbemFlagForwardOnly =&h20

arrComputers = Array("*") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "=========================================="

arrComputers = Array(“*”)For eachCompComputer in arrComputers WScript.Echo WScript.Echo“============================== ============“WScript.Echo”计算机:“&strComputer WScript.Echo”======================== ==================”

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ClassicCOMClass", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)

设置objWMIService = GetObject(“winmgmts:\”&strComputer&“\ root \ CIMV2”)设置colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_ClassicCOMClass”,“WQL”,_ wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems WScript.Echo "Caption: " & objItem.Caption WScript.Echo "ComponentId: " & objItem.ComponentId WScript.Echo "Description: " & objItem.Description WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate) WScript.Echo "Name: " & objItem.Name WScript.Echo "Status: " & objItem.Status WScript.Echo Next Next

对于每个objItem在colItems中WScript.Echo“Caption:”&objItem.Caption WScript.Echo“ComponentId:”&objItem.ComponentId WScript.Echo“Description:”&objItem.Description WScript.Echo“InstallDate:”&WMIDateStringToDate(objItem。 InstallDate)WScript.Echo“Name:”&objItem.Name WScript.Echo“Status:”&objItem.Status WScript.Echo Next Next

Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function

函数WMIDateStringToDate(dtmDate)WScript.Echo dtm:WMIDateStringToDate = CDate(Mid(dtmDate,5,2)&“/”&_ Mid(dtmDate,7,2)&“/”&Left(dtmDate,4)_&“ “&Mid(dtmDate,9,2)&”:“&Mid(dtmDate,11,2)&”:“&Mid(dtmDate,13,2))结束功能

#1


Scritomatic V2 tool have some sample like that :

Scritomatic V2工具有一些样本:


On Error Resume Next

Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20

Const wbemFlagReturnImmediately =&h10 Const wbemFlagForwardOnly =&h20

arrComputers = Array("*") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "=========================================="

arrComputers = Array(“*”)For eachCompComputer in arrComputers WScript.Echo WScript.Echo“============================== ============“WScript.Echo”计算机:“&strComputer WScript.Echo”======================== ==================”

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ClassicCOMClass", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)

设置objWMIService = GetObject(“winmgmts:\”&strComputer&“\ root \ CIMV2”)设置colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_ClassicCOMClass”,“WQL”,_ wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems WScript.Echo "Caption: " & objItem.Caption WScript.Echo "ComponentId: " & objItem.ComponentId WScript.Echo "Description: " & objItem.Description WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate) WScript.Echo "Name: " & objItem.Name WScript.Echo "Status: " & objItem.Status WScript.Echo Next Next

对于每个objItem在colItems中WScript.Echo“Caption:”&objItem.Caption WScript.Echo“ComponentId:”&objItem.ComponentId WScript.Echo“Description:”&objItem.Description WScript.Echo“InstallDate:”&WMIDateStringToDate(objItem。 InstallDate)WScript.Echo“Name:”&objItem.Name WScript.Echo“Status:”&objItem.Status WScript.Echo Next Next

Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function

函数WMIDateStringToDate(dtmDate)WScript.Echo dtm:WMIDateStringToDate = CDate(Mid(dtmDate,5,2)&“/”&_ Mid(dtmDate,7,2)&“/”&Left(dtmDate,4)_&“ “&Mid(dtmDate,9,2)&”:“&Mid(dtmDate,11,2)&”:“&Mid(dtmDate,13,2))结束功能