当我重定向标准输出时,新脚本的处理窗口不会显示所有打印内容(显然,因为它已被重定向...)。
是否可以在脚本窗口(PowerShell或Python)中显示打印内容并在过程结束后捕获其输出?
var process = new Process {
StartInfo = {
FileName = path,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true, // I want to capture stdout
}
};
using (process) {
process.Start();
process.WaitForExit();
var stdout = await process.StandardOutput.ReadToEndAsync().ConfigureAwait(false);
// I do have the output in stdout now, but the script's window hasn't shown anything while it was running.
// It makes me sad :-(
}