Access Windows XP SP2 Security Center via WMI铪铪铪

From http://www.pcmag.com/article2/0,1759,1639276,00.asp

According to Microsoft, WMI is the Microsoft implementation of Web-Based Enterprise Management (WBEM), an industry standard for accessing management information on a system. For Windows XP Service Pack 2, Microsoft added new fields or records to keep track of the Firewall and Antivirus information in the WMI database. The WMI database is designed to be accessible via the WBEM API (application program interface) and is available to any program that wants to access the WMI. These programs can be desktop applications written in desktop- or web-based scripting or ActiveX modules. 

make a WMI query in root/SecurityCenter to find out which security product is installed in the system.

Set objSWbemServices = GetObject("winmgmts://./root/SecurityCenter")
Set colFirewall = objSWbemServices.ExecQuery("Select * From antivirusProduct",,48)
For Each objAntiVirusProduct In colFirewall
Echo(" " & objAntiVirusProduct.productUptoDate)
Next

You may also use the WbemScripting.SWbemLocator object 

From http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21645145.html

Private Sub DumpFirewallInfo()

Dim oLocator    As WbemScripting.SWbemLocator
Dim oService    As WbemScripting.SWbemServicesEx
Dim oFirewalls  As WbemScripting.SWbemObjectSet
Dim oFirewall   As WbemScripting.SWbemObjectEx
Dim oFwMgr      As Variant
   
   
    Set oFwMgr = CreateObject("HNetCfg.FwMgr")
   
    Debug.Print "Checking the Windows Firewall..."
    Debug.Print "Windows Firewal Enabled: " & oFwMgr.LocalPolicy.CurrentProfile.FirewallEnabled
    Debug.Print ""
   
    Set oFwMgr = Nothing
   
   
    Debug.Print "Checking for other installed firewalls..."
   
    Set oLocator = New WbemScripting.SWbemLocator
    Set oService = oLocator.ConnectServer(".", "root/SecurityCenter")
    oService.Security_.ImpersonationLevel = 3

    Set oFirewalls = oService.ExecQuery("SELECT * FROM FirewallProduct") ' This could also be "AntivirusProduct"
   
    For Each oFirewall In oFirewalls
        Debug.Print "Company:       " & vbTab & oFirewall.CompanyName
        Debug.Print "Firewall Name: " & vbTab & oFirewall.DisplayName
        Debug.Print "Enabled:       " & vbTab & Format$(oFirewall.Enabled)
        Debug.Print "Version:       " & vbTab & oFirewall.versionNumber
        Debug.Print ""
    Next oFirewall
   
    Set oFirewall = Nothing
    Set oFirewalls = Nothing
    Set oService = Nothing
    Set oLocator = Nothing

End Sub

more informatin about Wbem Scripting can be found at http://msdn.microsoft.com/library/en-us/wmisdk/wmi/creating_an_object_using_vbscript.asp.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值