0

I'm testing an application in a stress test.
That's why I need it to restart if an error occurs (an error window opens) or it hangs or crashes. At the same time I need to collect all the useful information about the problem which lead to a restart: make a dump file and copy the error text from the error window (and/or take its screenshot).

With bash it's easy: Restarting program automatically on crash in OSX (without screenshots or dumps, but the error window stays on MacOS, so they are practically not needed there). However, I need this functionality to run on Win (XP/Vista/7).

I can use special monitoring tools for restart, but that way I would rely on non-standard programs. I can use User Mode Process Dumper on XP, but it doesn't work for Vista.

Is there any elegant and universal way (batch file or perl script would be great) to implement described functionality for all versions of Windows?

Community
  • 1
  • 1
evgeny9
  • 1,381
  • 3
  • 17
  • 31

1 Answers1

1

Regarding the 1st part of your question, you can test if a process is running using tasklist.
This will run myapp.exe, restarting it if necessary:

    @echo off
    set MYAPP=myapp.exe

    rem # Loop infinitely and restart the application if it's not running
:Start
    tasklist /FI "IMAGENAME eq %MYAPP%" 2>NUL | find /I /N "%MYAPP%" >NUL
    if errorlevel 1 %MYAPP%
    call :Sleep 1
    goto Start

    rem # A short sleep subroutine to yield system resources
:Sleep
    ping 127.0.0.1 -n %1 -w 1000 > nul

Regarding the 2nd part of your question, you can collect a user mode core dump using AutoDumpPlus.
For instance:

    adplus -crash -quiet -pn myapp.exe -o C:\temp

This will run ADPlus, monitoring all processes named myapp.exe, and producing a core dump in the output directory C:\temp (of course, this can be changed) if a crash is detected.

I haven't tested this setup as a whole, but I hope it works for you!

Eitan T
  • 32,660
  • 14
  • 72
  • 109
  • 1
    Sorry for the late response. You solution (with little modifications) worked for me, thank you. As for capturing the error window and its text (`Ctrl+C` on focused window) I used an [AutoIt](http://www.autoitscript.com/forum/) script based on [such one](http://www.devguru.in/2012/01/12/print-screen-with-autoit/#.UBuySfbiajQ). – evgeny9 Aug 03 '12 at 11:14