启动和停止应用程序进程
// Visual C#using System; using System.Diagnostics; using System.Windows.Forms; public class ManageProcess { public void StartNotepads() { Process StartProcess; StartProcess = Process.Start("Notepad.exe"); StartProcess = Process.Start("Notepad.exe"); StartProcess = Process.Start("Notepad.exe"); StartProcess = Process.Start("Notepad.exe"); Console.WriteLine("See all the notepads!!!"); Console.WriteLine("Press the enter key..."); Console.ReadLine(); } public void KillNotepads() { Process[] remoteByName = Process.GetProcessesByName("notepad",SystemInformation.ComputerName); Console.WriteLine("Running Instances of Notepad : " + remoteByName.Length); foreach (Process p in remoteByName) { Console.Write("Press Enter to kill a Notepad!!!"); Console.ReadLine(); p.Kill(); } } public static void Main() { ManageProcess StartProcess = new ManageProcess(); StartProcess.StartNotepads(); StartProcess.KillNotepads(); } }