System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); foreach(System.Diagnostics.Process myProcess in myProcesses) { if ("taskmgr"==myProcess.ProcessName) myProcess.Kill(); }
string ProcessName = "taskmgr"; Process[] MyProcess1 = Process.GetProcessesByName(ProcessName); Process MyProcess = new Process(); MyProcess.StartInfo.FileName = "cmd.exe"; MyProcess.StartInfo.UseShellExecute = false; MyProcess.StartInfo.RedirectStandardInput = true; MyProcess.StartInfo.RedirectStandardOutput = true; MyProcess.StartInfo.RedirectStandardError = true; MyProcess.StartInfo.CreateNoWindow = true; MyProcess.Start(); MyProcess.StandardInput.WriteLine("ntsd -c q -p " + (MyProcess1[0].Id).ToString()); MyProcess.StandardInput.WriteLine("Exit");
System.Collections.ArrayList procList = new System.Collections.ArrayList(); string tempName = ""; int begpos; int endpos; foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses()) { tempName = thisProc.ToString(); begpos = tempName.IndexOf("(") + 1; endpos = tempName.IndexOf(")"); tempName = tempName.Substring(begpos, endpos - begpos); procList.Add(tempName); if (tempName == "taskmgr") { if (!thisProc.CloseMainWindow()) thisProc.Kill(); } }
System.Collections.ArrayList procList = new System.Collections.ArrayList(); string tempName = ""; int begpos; int endpos; foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses()) { tempName = thisProc.ToString(); begpos = tempName.IndexOf("(") + 1; endpos = tempName.IndexOf(")"); tempName = tempName.Substring(begpos, endpos - begpos); procList.Add(tempName); if (tempName == "taskmgr") { if (!thisProc.CloseMainWindow()) thisProc.Kill(); }//这个相当不错 }