如何检测Windows Server 2008上的防病毒在C#中? [英] How to detect antivirus on Windows Server 2008 in C#?

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

问题描述

我看到类似下面的无数次代码示例中我寻找一个答案:

I have seen code samples similar to the following numerous times in my search for an answer:

using System;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
  class Program
  {
    public static bool AntivirusInstalled()
    {

      string wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
      try
      {
        ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
        ManagementObjectCollection instances = searcher.Get();
        return instances.Count > 0;
      }

      catch (Exception e)
      {
        Console.WriteLine(e.Message);
      }

      return false;
    } 

    public static void Main(string[] args)
    {
      bool returnCode = AntivirusInstalled();
      Console.WriteLine("Antivirus Installed " + returnCode.ToString());
      Console.WriteLine();
      Console.Read();
    }

  }
}



不幸的是,它出现在Windows Server 2008不具备安全中心 SecurityCenter2 命名空间,所以我得到一个无效的命名空间例外。

Unfortunately, it appears that Windows Server 2008 does not have the SecurityCenter or SecurityCenter2 namespace, so I get an Invalid namespace exception when trying this approach.

有谁知道的一种方式,以确定是否存在Windows Server 2008上运行防病毒软件?任何帮助表示赞赏!

Does anyone know of a way to determine if there is antivirus software running on Windows Server 2008? Any help is appreciated!

推荐答案

我前一段时间遇到这个问题的客户端和我结束了表演上的一个dictonary搜索本地系统驱动程序和流程寻找的模式了解防病毒签名(如文件夹名称,进程名称,等等)这不是100%肯定,因为有人的地方就会donwload一个全新的反病毒,你是没有意识,但是,除了,这是非常有效的...

I faced this problem some time ago for a client and I ended up performing a dictonary search on the local system drivers and processes looking for a pattern of know anti-virus signatures (such as folder names, processes names, etc...) it's not 100% sure because somewhere someone will donwload a brand new anti-virus that you're unware of, but that apart, it was very effective...

这篇关于如何检测Windows Server 2008上的防病毒在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆