[英]When calling a .bat file using C#, how can I make the cmd window show what the batch file is doing?
我正在使用在C#中创建的Windows窗体来执行批处理文件。 批处理文件运行,并且显示cmd窗口,但是该窗口为空白,并且不显示该批处理文件正在执行的任何命令。 有什么方法可以使CMD窗口显示正在执行的操作吗? 相关代码段如下。
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + "\"C:\\tf_Test2.bat\"");
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
var process = Process.Start(processInfo);
process.WaitForExit();
将UseShellExecute
更改为true
并删除对重定向输出流的支持。 实际上,您是在告诉Windows您不希望输出进入控制台窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.