C# 扫描完成后试图关闭防病毒软件

C# 扫描完成后试图关闭防病毒软件,c#,C#,我试图在扫描完成时关闭Malwarebytes和其他防病毒程序,目前我使用CPU使用率作为扫描完成的标志,但Malwarebytes运行多个进程,我的程序在大多数时间仅拾取CPU使用率为0%的进程 这是我的密码 public static PerformanceCounter process_cpu = new PerformanceCounter("Process","% Processor Time", "mbam"); public static Process proc

我试图在扫描完成时关闭Malwarebytes和其他防病毒程序,目前我使用CPU使用率作为扫描完成的标志,但Malwarebytes运行多个进程,我的程序在大多数时间仅拾取CPU使用率为0%的进程 这是我的密码

    public static PerformanceCounter process_cpu = new PerformanceCounter("Process","% Processor Time", "mbam");
    public static Process proc = new Process();

    private void timer1_Tick(object sender, EventArgs e)
    {
        double CPU_use = process_cpu.NextValue();
        temp = temp + CPU_use;
        Count += 1;
        TBX1.Text = Count + ": Seconds Opened";

        if (proc.Responding)
        {
            TBX1.Text += "  Status = Running  CPU usage is " + CPU_use;

            if (temp <=  0 && Count % 20 == 0) //this checks every 20 secs
            {
                MessageBox.Show("Finished?", "END"); //This is temporary, it will just end the program 
            }
            if (Count % 20 == 0)
            {
                temp = 0;
            }
        }
        else
        {
            TBX1.Text += "  Status = Not Responding";
        }  
    }
public static PerformanceCounter process\u cpu=new PerformanceCounter(“进程”,“处理器时间”,“mbam”);
公共静态进程proc=新进程();
私有无效计时器1_刻度(对象发送方,事件参数e)
{
双CPU_use=process_CPU.NextValue();
温度=温度+CPU使用;
计数+=1;
TBX1.Text=Count+“:打开秒数”;
如果(过程响应)
{
TBX1.Text+=“Status=正在运行的CPU使用率为”+CPU\u使用率;

如果(temp似乎如果你能得到MBAM的PID,你可以检查所有进程,看看它们是否是它的子进程:。这对你有用吗?测试完成后,Malwarebytes会弹出一个记事本窗口。你可以让你的程序定期检查该窗口,并在弹出后关闭Malwarebytes。这只是一个解决方法和问题仅当这是供个人使用时,就足够了。您不必保持计数来检查20秒。您创建的计时器对象应该有一个Interval属性,可以设置为20000,因为该属性是以毫秒为单位设置的。Andrew,我不完全确定它的措辞,我需要获取一个进程的PID并跟踪CPU使用它。不幸的是,这不仅仅是malwarebytes,它也是oter程序,但谢谢你Todorov。我每秒钟都在数一些东西,所以这是最简单的方法。谢谢你的回复