Stop a Group of Processes

gbertoli3 0 Tallied Votes 126 Views Share

Stop a Group of Processes

/// <summary>
        /// Stops a group of processes.
        /// </summary>
        /// <param name="Processes">The group to stop.</param>
        public static void StopGroup(String[] Processes)
        {
            for (int i = 0; i < Processes.Length; i++)
            {
                foreach (System.Diagnostics.Process process in System.Diagnostics.Process.GetProcesses())
                {
                    if (process.ProcessName.ToLower() == Processes[i].ToLower())
                    {
                        process.Kill();
                    }
                }
            }
        }