首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >打开和关闭防病毒软件

打开和关闭防病毒软件
EN

Stack Overflow用户
提问于 2012-03-29 06:08:12
回答 2查看 1.9K关注 0票数 2

有没有办法检测使用C#的机器上是否安装了防病毒软件?我知道安全中心会检测到杀毒软件,但你如何在C#?And中检测到它,如何在C#中关闭和打开它?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-03-29 06:12:03

如何检测:请参阅以下问题:Detect Antivirus on Windows using C#

如何关闭和打开:据我所知,没有简单,常见的方法来关闭杀毒软件。这是一件好事!关闭防病毒软件应该始终是用户(或企业环境中的管理员)的有意识的选择,而不是第三方产品可以轻松完成的事情。

票数 5
EN

Stack Overflow用户

发布于 2021-12-03 04:54:57

要以字符串形式返回AntiVirus名称,请执行以下操作:

代码语言:javascript
运行
AI代码解释
复制
 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;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9919934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文