/// <summary>
   /// 找到并关闭指定进程
   /// 例如:"PPAP","knbcenter","PPSKernel","WordBook","BFAssistantSvc"
   /// </summary>
   /// <param name="argProcessNames">进程名称</param>
    static void KillProcess(List<string> argProcessNames)
    {
        List<string> processNames = new List<string>();
        foreach (string item in argProcessNames)
        {
            if (!processNames.Contains(item.ToUpper()))
                processNames.Add(item.ToUpper());
        }
        Process[] a = Process.GetProcesses();
        for (int i = 0; i < a.Count(); i++)
        {
            Process p = a[i];
            string str = p.ProcessName;
            Console.WriteLine(str);
            if (processNames.Contains(str.ToUpper()))
            {
                a[i].Kill();
                Console.WriteLine("关闭进程" + str);
            }
        }
        Console.ReadKey();
    }

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2022-01-11
  • 2021-09-04
  • 2021-03-31
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案