从批处理文件运行程序崩溃时显示错误
我在 Windows 中有一个批处理文件 (.bat),我用它来运行程序。问题是有时程序会崩溃,我想知道什么时候会崩溃。如果我在资源管理器窗口中双击程序的 .exe 并且程序崩溃(就像缺少 .dll),那么我会收到类似这样的消息,
The program can't start because XXXX.dll is missing from your computer. Try reinstalling the program to fix this problem.
但是当我通过 .bat 文件运行程序时,我没有收到任何 消息表明程序崩溃 - 没有弹出窗口,没有输出到命令行。
我猜这与 .bat 文件吸收错误消息有关。作为参考,我的 .bat 文件如下所示(缩短以保持帖子简单):
start directory\program.exe
我想得到程序已崩溃的指示。我可以在 .bat 文件中添加一些内容来查看吗?
I have a batch file (.bat) in Windows which I am using to run a program. The problem is sometimes the program crashes and I'd like to know when it does. If I double-click the program's .exe in an Explorer window and the program crashes (like if a .dll is missing) then I get a message like
The program can't start because XXXX.dll is missing from your computer. Try reinstalling the program to fix this problem.
But when I run the program through the .bat file, I don't get any indication that the program crashes - no popup, no output to the command line.
I'm guessing it has something to do with the .bat file absorbing the error message. For reference my .bat file looks like this (shortened to keep the post simple):
start directory\program.exe
I'd like to get an indication that the program has crashed. Is there something I can add to my .bat file to see that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 start 命令会创建一个新的命令行窗口供 program.exe 运行。当 program.exe 退出时,该窗口会立即关闭,从而向您隐藏错误。
要修复它,只需将“启动目录\program.exe”更改为“目录\program.exe”
Using the start command creates a new command line window for program.exe to run in. That window closes immediately when program.exe exits, thereby hiding the error from you.
To fix it, simply change "start directory\program.exe" to "directory\program.exe"