Start New Discussion within our Software Development Community

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();
                    }
                }
            }
        }