启动和停止应用程序进程

来源:互联网 发布:招聘网络主播可信吗 编辑:程序博客网 时间:2024/05/14 09:18

启动和停止应用程序进程

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

0 0
原创粉丝点击