投机取巧的做法如下:
- C# code
-
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("tasklist /V");
p.StandardInput.WriteLine("exit");
string strRst = p.StandardOutput.ReadToEnd();
string tag="========================================================================";
string w = strRst.Substring(strRst.IndexOf(tag) + tag.Length);
string[] res = w.Split('"n');
浙公网安备 33010602011771号