C# 结束任务栏指定进程

        public static void KillProcess(string processName)
        {
            System.Diagnostics.Process myproc = new System.Diagnostics.Process();
            //得到所有打开的进程
            try
            {
                foreach (Process thisproc in Process.GetProcessesByName(processName))
                {
                    if (!thisproc.CloseMainWindow())
                    {
                        if (thisproc != null)
                            thisproc.Kill();
                    }
                }
            }
            catch (Exception Exc)
            {
                throw Exc;   
            }
        }

用法:

            KillProcess("Excel");


你可能感兴趣的:(exception,String,C#,Excel,null,任务)