The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Q & A: How Can I Generate a Crash Dump Before AlwaysUp Restarts my Application?

Q & A
  Occasionally the application we’re running as a service stops responding, resulting in AlwaysUp restarting it. We would like to run a script prior to the restart to try to generate a crash-dump file so we can find out where the problem is. Is that possible?

— Kelly @ Sabre

Hi Kelly. Sorry to hear of the trouble! Please follow these steps to automatically generate a crash dump whenever your application terminates:

  1. Download & install Microsoft’s free ProcDump utility

    ProcDump — yet another excellent utility from the Sysinternals team — easily creates a dump file from any running process. It is our tool of choice when exploring application crashes.

    Download the ProcDump .Zip package and extract all files to a convenient location. We have placed the files in “C:\Apps\ProcDump” for this article.

    Be sure to run ProcDump at least once and accept the Sysinternals EULA. We don’t want the utility to hang when we run it unattended as a background service!

  2. Compose the command line to capture a crash dump when your application stops

    ProcDump features an impressive set of command line options. Please review and identify the flags that work best for your situation.

    For example, we use this command to dump the notepad.exe application whenever it stops running:

    c:\Apps\ProcDump\procdump.exe -t notepad

    Please ensure that this command works as expected. Start your application, run the command and then terminate your application. Is a dump file created? Troubleshot and fix if not.

  3. Setup your ProcDump command as a Windows Service in AlwaysUp

    Your application is running 24×7. To configure ProcDump to operate on the same schedule and capture the dump file at any time:

    1. Start AlwaysUp and select Application > Add… to bring up the Add Application window.

    2. On the General tab:

      In the Name field, enter a suitable name for this new service. We have used “ProcDump Notepad”.

      In the Application field, enter the full path to ProcDump.exe.

      In the Arguments field, provide the command line options you developed in step 2. Be sure to add the -w flag, which will cause ProcDump to wait for your app to launch if necessary.

      And in the Start in directory field, enter the folder where you want the dump files to be written. (Leaving this blank will cause dump files to be created in the ProcDump folder.)


      ProcDump Notepad Service Settings - General

    3. On the Logon tab, specify your windows account. ProcDump should run in this account since you know it works there (and that the EULA has been accepted).


      ProcDump Notepad Service Settings - Logon

    4. Click the Save >> button to record the ProcDump service.

    5. And finally, start your new service (from the Application menu).

      Here is what the finished setup looks like for us, with Notepad running as a service and ProcDump monitoring it (also as a service):


      ProcDump Notepad Service Settings - Logon

  4. Test

    Now that everything is in place, you should confirm that a crash dump will be created whenever your application stops.

    Open the Task Manager and kill your application. Does a new dump file appear in the expected location? If not, please review all the steps and ensure that nothing was missed.

Best of luck debugging your program!

Posted in AlwaysUp | Tagged , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *