我在寻找答案时已经看到类似于以下多次的代码示例:
原文链接:https://www.f2er.com/windows/372537.htmlusing 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没有SecurityCenter或SecurityCenter2命名空间,因此在尝试此方法时,我会收到无效的命名空间异常。
有没有人知道如何确定Windows Server 2008上是否有防病毒软件运行?任何帮助是赞赏!