using System; using System.Diagnostics; class Program { static void Main(string[] args) { ProcessStartInfo info = new ProcessStartInfo("IExplore.exe"); //准备启动IE info.WindowStyle = ProcessWindowStyle.Maximized; //IE最大化 info.Arguments = "www.google.cn"; //参数 Process.Start(info); //启动进程 //也可以用下面方法启动进程 // Process.Start("IExplore.exe","www.google.cn"); //Process.Start(@"D:\Program Files\Tencent\QQ\Bin\QQ.exe"); // 路径不在Windows环境变量时,须指明绝对路径 Console.WriteLine("所有进程列表:"); Process[] proc = Process.GetProcesses(); foreach (Process p in proc) { Console.WriteLine(p.ProcessName); } Console.WriteLine("请输入你要关闭的进程名称: "); string processName = Console.ReadLine(); Process[] closeProc = Process.GetProcessesByName(processName); if (closeProc.Length > 0) { foreach (Process p in closeProc) { p.CloseMainWindow(); //相当于用户直接单击主窗体上的“关闭”按钮,退出前请求用户验证 //p.Kill(); //强制关闭,直接结束进程 p.Close(); } } else { Console.WriteLine("输入的进程不存在"); } Console.ReadKey(); } }