Hi All,
While running a batch file. If ever any program crashes. A windows error message prompts and stops the process until the OK button is not clicked.:( Is there any way where I can capture the crashes without stopping the running process or I can put in some more commands in the batch file which will do the job for me.:cool:

Dani AI

Generated

Short answer: the OS dialog you see is generated when a program has an unhandled exception; that dialog is outside the batch file and will block the crashed process (and thus any batch line that is waiting on it) until someone dismisses it. There are two practical approaches: (A) keep the batch running by launching the program asynchronously, and (B) have a crash logger/watchdog capture the failure automatically (DrWatson or a tool like ProcDump).

Clarifying : cmd.exe does not have an ON ERROR statement like some older BASICs. For batch error handling use IF ERRORLEVEL, the %ERRORLEVEL% variable, or the conditional operators && and || to react to a program exit code.

Examples you can use right away:

REM start app asynchronously so the batch doesn't wait for it (no OK click needed)
start "" "C:\Path\To\App.exe" arg1 arg2 > "C:\logs\App.out" 2>&1

REM run and wait, then check exit code (this WILL block if the app shows an OS crash dialog)
"C:\Path\To\App.exe" arg1 arg2
if %ERRORLEVEL% neq 0 echo App failed with %ERRORLEVEL% >> crash.log

To capture crash details without user interaction:

  • Use DrWatson (built into Windows 2000). Run drwtsn32 -i to register it as the postmortem debugger, then run drwtsn32 to set log and dump creation options. That will collect crash logs/dumps automatically when an app faults.
  • For a scriptable, robust alternative, use Sysinternals ProcDump to start/monitor a process and produce a crash dump on an unhandled exception (recommended for automated collection and analysis).

Do not disable global error handling on production machines unless you understand the security and support implications. If you need a wrapper that times out or kills a hung process, build a launcher that starts the target with start, monitors it (tooling like tasklist/pslist or ProcDump helps), and logs any crash/dump files for later analysis.

Recommended Answers

All 5 Replies

Batch script has an ON ERROR function to redirect batch execution to a section designed to handle errors.

If an error occurs, the program with the error can not keep running.

:)Hey can u give me some more details. CLEARCUT IDEA with all the commands.Or u give me the link from where i can read it out.
Thanks in advance.

:)And I am talking abt BATCH FILES USING DOS COMMANDS running on WINDOWS 2000 machine.

Somehow I have let all of my my MS-DOS books get away from me. I can't find any of them.

How can i suppress a user prompt while running a batch file in windows 2000 machine?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.