加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows Server 2008中检测C#中的防病毒?

发布时间:2020-12-13 20:59:26 所属栏目:Windows 来源:网络整理
导读:我在寻找答案时已经看到类似于以下多次的代码示例: using System;using System.Text;using System.Management;namespace ConsoleApplication1{ class Program { public static bool AntivirusInstalled() { string wmipathstr = @"" + Environment.Machin
我在寻找答案时已经看到类似于以下多次的代码示例:
using System;
using System.Text;
using System.Management;

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

      string wmipathstr = @"" + Environment.MachineName + @"rootSecurityCenter";
      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没有SecurityCenter或SecurityCenter2命名空间,因此在尝试此方法时,我会收到无效的命名空间异常。

有没有人知道如何确定Windows Server 2008上是否有防病毒软件运行?任何帮助是赞赏!

前一段时间我遇到了一个客户端的问题,我最终对本地系统驱动程序和进程进行了一个双向搜索,寻找一个已知的反病毒签名模式(如文件夹名称,进程名称等)不是100%肯定的,因为某个人将会淹没一个全新的反病毒,你不知道,但除此之外,它是非常有效的…

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读