是否有c#等同于此?我尝试使用WMI,并且只需获得" Windows Defender",而不管安装了WMI符合WMI的防病毒软件。
我只想在文本框中显示这些结果。
WMIC /Node:localhost /Namespace:\rootSecurityCenter2 Path AntiVirusProduct Get displayName /Format:List
当我使用上面的代码时,我会得到防病毒的实际名称。
您可以向System.Management
添加引用。然后使用ManagementObjectSearcher
您可以运行WMI查询。
要查找应在SecurityCenter2
中搜索的安装防病毒。例如:
var path = string.Format(@"\{0}rootSecurityCenter2", Environment.MachineName);
var searcher = new ManagementObjectSearcher(path, "SELECT * FROM AntivirusProduct");
var instances = searcher.Get().Cast<ManagementObject>()
.Select(x => (string)x.GetPropertyValue("displayName"))
.ToList();
注1:对于Windows XP,在SecurityCenter
中搜索。
注2:您也可以读取AntiVirusProduct
的其他属性:
-
displayName
:string
-
instanceGuid
:string
-
pathToSignedProductExe
:string
-
pathToSignedReportingExe
:string
-
productState
:UInt32
。(有关如何解析状态的信息,请查看此帖子。) -
timestamp
:string