本文介绍了检查在C#中的防病毒状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查一组服务器的看防病毒是否是最新的最新运行。棘手的事情是,他们分布在Windows 2003和2008服务器,我需要能够检查他们所有。

I need to check a group of servers to see whether the anti virus is up-to-date and running. Tricky thing is that they are spread over Windows 2003 and 2008 servers and I need to be able to check them all.

有没有用C#或VB这样做的任何方式。净?

Is there any way of doing this with C# or VB.NET?

我略略看了看周围使用WMI,但它出现在2008 / WIN7电脑微软已经改变了他们给什么信息反馈给你。

I have briefly looked around using WMI, but it appears on 2008/win7 computers Microsoft has changed what information they give back to you.

在总结,我需要以下内容:

In summary, I need the following:


  • AV名称

  • AV版

  • AV截至到日期

  • AV启用/运行

  • AV name
  • AV version
  • AV Up-to-Date
  • AV Enabled/Running

谁能帮

推荐答案

样品可以发现的你提到使用WMI。海报国家这是在一套Win 7的机器上完成的;所以下面的代码应该让你开始...

Sample can be found here using WMI as you mentioned. The poster states this is being done on a Win 7 machine; so the code below should get you started...

ConnectionOptions _connectionOptions = new ConnectionOptions();
//Not required while checking it in local machine.
//For remote machines you need to provide the credentials
//options.Username = "";
//options.Password = "";
_connectionOptions.EnablePrivileges = true;
_connectionOptions.Impersonation = ImpersonationLevel.Impersonate;
//Connecting to SecurityCenter2 node for querying security details
ManagementScope _managementScope = new ManagementScope(string.Format("\\\\{0}\\root\\SecurityCenter2", ipAddress), _connectionOptions);
_managementScope.Connect();
//Querying
ObjectQuery _objectQuery = new ObjectQuery("SELECT * FROM AntivirusProduct");
ManagementObjectSearcher _managementObjectSearcher =
    new ManagementObjectSearcher(_managementScope, _objectQuery);
ManagementObjectCollection _managementObjectCollection = _managementObjectSearcher.Get();
if (_managementObjectCollection.Count > 0)
{
    foreach (ManagementObject item in _managementObjectCollection)
    {
        Console.WriteLine(item["displayName"]);
        //For Kaspersky AntiVirus, I am getting a null reference here.
        //Console.WriteLine(item["productUptoDate"]);

        //If the value of ProductState is 266240 or 262144, its an updated one.
        Console.WriteLine(item["productState"]);
    }
}

这篇关于检查在C#中的防病毒状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 21:59