c#下执行带多个参数的控制台命令

2015-12-05  本文已影响600人  我家有个小太阳

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

原文地址

上一篇 下一篇

猜你喜欢

热点阅读