如何以编程方式获取已安装的防病毒软件和防火墙?
Posted
技术标签:
【中文标题】如何以编程方式获取已安装的防病毒软件和防火墙?【英文标题】:How do I get the installed antivirus software and firewall programmatically? 【发布时间】:2014-03-03 17:58:07 【问题描述】:如何获取有关 Windows 计算机上安装的防病毒软件和防火墙软件的信息?
【问题讨论】:
假装你在危险中;将其重新表述为要解决的特定问题的问题,并将您的解决方案作为问题的答案发布。 【参考方案1】:您可以使用 ManagementObjectSearcher 获取此信息。
Public Function GetAntivirus() As String
Try
Dim data As String = String.Empty
For Each firewall As ManagementObject In New ManagementObjectSearcher("root\SecurityCenter" & IIf(My.Computer.Info.OSFullName.Contains("XP"), "", "2").ToString, "SELECT * FROM AntiVirusProduct").Get
data &= firewall("displayName").ToString
Next
If Not data = String.Empty Then
Return data
Else
Return "No Antivirus"
End If
Catch
Return "No Antivirus"
End Try
End Function
Public Function GetFirewall() As String
Try
Dim data As String = String.Empty
For Each firewall As ManagementObject In New ManagementObjectSearcher("root\SecurityCenter" & IIf(My.Computer.Info.OSFullName.Contains("XP"), "", "2").ToString, "SELECT * FROM FirewallProduct").Get
Data &= firewall("displayName").ToString
Next
If Not data = String.Empty Then
Return data
Else
Return "No Firewall"
End If
Catch
Return "No Firewall"
End Try
End Function
【讨论】:
以上是关于如何以编程方式获取已安装的防病毒软件和防火墙?的主要内容,如果未能解决你的问题,请参考以下文章
Powershell:查找已安装的防病毒软件和状态,过滤掉 Windows Defender