从批处理文件运行程序崩溃时显示错误

发布于 2024-11-28 07:22:39 字数 496 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄居者 2024-12-05 07:22:39

使用 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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文