有没有办法检测使用C#的机器上是否安装了防病毒软件?我知道安全中心会检测到杀毒软件,但你如何在C#?And中检测到它,如何在C#中关闭和打开它?
发布于 2012-03-29 06:12:03
如何检测:请参阅以下问题:Detect Antivirus on Windows using C#
如何关闭和打开:据我所知,没有简单,常见的方法来关闭杀毒软件。这是一件好事!关闭防病毒软件应该始终是用户(或企业环境中的管理员)的有意识的选择,而不是第三方产品可以轻松完成的事情。
发布于 2021-12-03 04:54:57
要以字符串形式返回AntiVirus名称,请执行以下操作:
public static string Antivirus()
{
try
{
string firewallName = string.Empty;
// starting with Windows Vista we must use the root\SecurityCenter2 namespace
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\\" + Environment.MachineName + @"\root\SecurityCenter2", "Select * from AntivirusProduct"))
{
foreach (ManagementObject mObject in searcher.Get())
{
firewallName += mObject["displayName"].ToString() + "; ";
}
}
firewallName = RemoveLastChars(firewallName);
return (!string.IsNullOrEmpty(firewallName)) ? firewallName : "N/A";
}
catch
{
return "Unknown";
}
}
public static string RemoveLastChars(string input, int amount = 2)
{
if (input.Length > amount)
input = input.Remove(input.Length - amount);
return input;
}
https://stackoverflow.com/questions/9919934
复制相似问题