1 private static string CmdName = "cmd"; 2 /// <summary> 3 /// 关闭进程 4 /// </summary> 5 /// <param name="processName">进程名</param> 6 private void KillProcess(string processName) 7 { 8 Process[] myproc = Process.GetProcesses(); 9 foreach (Process item in myproc) 10 { 11 if (item.ProcessName == processName) 12 { 13 item.Kill(); 14 } 15 } 16 }
调用方式:
KillProcess(CmdName);
时间: 2024-12-24 22:04:55