我想启动一个 cmd 文件并将输出重定向到控制台,但它不起作用。我必须做什么?我已经设置了 startInfo.RedirectStandardOutput = true
。
com = "Parameter";
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo =
new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = Properties.Settings.Default.pathTo+ @"\Make\copy.cmd";
startInfo.Arguments = com;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
process.StartInfo = startInfo;
process.Start();
output = process.StandardOutput;
string ln;
while ((ln = output.ReadLine()) != null)
{
Console.WriteLine(line);
}
process.WaitForExit();