public static void GetConsolData(String exe, String cmd) { Process t_process = new Process(); t_process.StartInfo.FileName = exe;//调用控制台程序名称 t_process.StartInfo.UseShellExecute = false; t_process.StartInfo.RedirectStandardInput = true; t_process.StartInfo.RedirectStandardOutput = true; t_process.StartInfo.RedirectStandardError = true; t_process.StartInfo.CreateNoWindow = true; t_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; t_process.StartInfo.Arguments = cmd; t_process.Start(); StreamReader sr = t_process.StandardOutput; Console.WriteLine(sr.ReadToEnd()); }
网友评论