生成具有不同输出的控制台子进程
我有一个用 C# 编写的控制台应用程序,它启动一个新进程。这个新进程也是一个控制台应用程序。问题是整个子进程输出都转到父控制台窗口,但我不希望它这样做。它是否创建一个新的控制台窗口并不重要,我不需要它。
编辑:
Process p = new Process();
p.StartInfo.FileName = @"C:\example.exe";
p.Start();
我尝试了一些额外的设置,如 CreateNoWindow、RedirectOutput 等,但没有运气
I have a console application written in c# which starts a new process. This new process is also a console application. The problem is that whole child process output goes to parent console window and i don't want it to. It doesn't matter if it creates a new console window or not, I don't need it.
Edit:
Process p = new Process();
p.StartInfo.FileName = @"C:\example.exe";
p.Start();
I tried some additional setting like CreateNoWindow, RedirectOutput and so on but with no luck
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,当您创建子进程时,会弹出一个新的控制台窗口,并且子进程的所有输出最终都在该窗口中。以下是展示此行为的示例程序:
Normally, when you create a child process, a new console window pops up and all output of the child process ends up in that window. Here is a sample program that exhibits this behavior: