将执行进程的输出定向到当前 cmd
我可以通过 JScript 脚本执行程序,以便将执行的程序的输出写入当前控制台吗?
目前我正在使用 Shell.Application.ShellExecute,它正在为执行的应用程序打开另一个新控制台。
在我的例子中,JScript 是一个编译器的包装器,它是通过 ShellExecute 执行的。因此,所有编译器错误都会丢失,因为它们被打印在另一个控制台中。
Can I execute a program from a JScript script in such a way that the out put of the executed program will be written to the current console?
Currently I am using Shell.Application.ShellExecute and it is opening another new console for the executed application.
The JScript in my case is a wrapper around a compiler which is executed with the ShellExecute. So what happens is that all the compiler errors are lost because they are printed in another console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您担心的只是捕获编译器输出,那么您可以将输出重定向到文件(我建议 stdout 和 stderr)。像这样的事情:
如果你真的想在当前的控制台窗口中看到输出(我不怪你),那么你可以使用这个:
注意 - 如果你的命令有可能要求输入,那么你必须提供输入通过命令字符串中的管道或重定向(或者您可以将输入重定向到 nul)。否则程序会挂起。
If all you are worried about is capturing your compiler output then you can redirect the output to a file (I suggest both stdout and stderr). Something like this:
If you really want to see the ouptut in your current console window (I don't blame you), then you can use this:
Note - if your command has the potential for asking for input, then you must provide input via a pipe or redirection in the command string (or you could redirect input to nul). Otherwise the program will hang.