如何随时捕获Windows中命令提示符的显示输出? [英] How to capture display output from a command prompt in Windows at any moment?

查看:45
本文介绍了如何随时捕获Windows中命令提示符的显示输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想捕获特定时间在命令提示符(cmd窗口)中显示的信息,并将其发送到文本文件.

I'm tring to capture de information shown in a command prompt (cmd window) at a specific moment and send it to a text file.

我有一个C/C ++应用程序,该应用程序由这样的批处理脚本启动:

I have an app in C/C++ that is launched by a batch script like this:

c:\myProgramInC.exe
echo "Ending with error"
PAUSE

myProgramInC.exe始终处于运行状态(无限循环),因此,如果我的脚本进入echo命令,则意味着我的应用程序终止.

myProgramInC.exe is always running (with an infinite loop) so if my script gets to the echo command it means my app ended with an abend.

我想得到的是脚本结束执行之前的前几行,因为myProgramInC.exe总是打印有关正在发生的事情的信息,这对于查看发生错误时发生的情况将非常有用.像这样

What I want to get is the previous lines before the end execution of the script since my myProgramInC.exe always prints info about what is going on and it would be very useful to see what it was happening when the error ocurred. Something like this

c:\myProgramInC.exe
**** Execution of process to get te previous N lines in the command prompt ****
echo "Ending with error"
PAUSE

我知道cmd窗口中有一个缓冲区,并且我一直在考虑从此类缓冲区中捕获所有这些数据.是否可以通过文本获取此信息并将其存储在文件中?

I know the cmd window have a buffer and I've been thinking to capture all of this data from such buffer. It is any way to get this info as text to store it in a file?

我一直在尝试一些更专业的方法,以便通过ProcDump进行内存转储,但是由于我同时运行各种myProgramInC.exe(每个程序都存储在不同的位置),因此我只收到消息多个进程与指定的名称匹配."而其他选项对我来说却无济于事,因为我的应用不会停止响应,只是结束了.

I'v been trying with something more professional shuch as to make a dump of the memory with ProcDump but since I have various myProgramInC.exe running at the same time (each one stored in a different location) I just get the message "Multiple processes match the specified name." and the rest of the options are just not useful for me since my app doesn't get unresponsive, it simply ends.

有什么想法吗?

推荐答案

您可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆