none
How to start WinDbg from the command line and save output to a file. RRS feed

  • Question

  • Hi All.

    I'd like to run WinDbg on some BSOD memory.dmp files.  I'd like to save the output to a file then parse the file. 

    How can I save the output of WinDbg to a file without opening up the WinDbg user interface.  Is there a command-line-only version of WinDbg?

    Tuesday, July 30, 2013 11:20 PM

Answers

  • Use cdb.exe, which is included with the debugger package, so it should be sitting right next to windbg.exe.

    You'll want to do something like

    cdb.exe -z c:\path\to\dump.dmp -y c:\path\to\symbols -c "!analyze -v; q" > c:\path\to\output.txt

    • Marked as answer by BlueUrgency Sunday, August 4, 2013 7:01 AM
    Wednesday, July 31, 2013 1:22 AM

All replies

  • Use cdb.exe, which is included with the debugger package, so it should be sitting right next to windbg.exe.

    You'll want to do something like

    cdb.exe -z c:\path\to\dump.dmp -y c:\path\to\symbols -c "!analyze -v; q" > c:\path\to\output.txt

    • Marked as answer by BlueUrgency Sunday, August 4, 2013 7:01 AM
    Wednesday, July 31, 2013 1:22 AM
  • Hi,

    Actually for kernel dumps you should use kd.exe:

    kd.exe -y SymbolPath -i ImagePath -z DumpFileName

    Thanks,

    Alon

    Wednesday, July 31, 2013 9:12 AM
  • windbg works fine from command line you can write batch scripts to using windbg with command line parameters

    assuming you have several dumps in a folder with extension .dmp

    a simple for /f script like below will open all the dumps in windbg (doesn't matter if it is user dump , kernel dump, minidump , fulldump , invalid dump ) run analyze -v on them save the output to a seperate log file with name of log file based on the dump file name and quit the debugging session

    if you have ten .dmp you will have ten .dmp.log files for later analysis

    for /F %I in ('dir /b *.dmp') do windbg  -QY -c ".logopen /d;!analyze -v;q" -z %I

    running this from cmd.exe will spawn multiple windbg and will process all dmp files in parallel

    copy paste this to a .bat file(edit %I to %%I and execute the bat file to run each dmp in series


    C:\dumps>dir /b
    00.dmp
    01.dmp
    02.dmp
    03.dmp
    04.dmp
    05.dmp
    06.dmp
    07.dmp
    autoanalyzedumps.bat

    C:\dumps>type autoanalyzedumps.bat
    for /F %%I in ('dir /b *.dmp') do windbg  -QY -c ".logopen /d;!analyze -v;q" -z
    %%I
    C:\dumps>autoanalyzedumps.bat

    C:\dumps>for /F %I in ('dir /b *.dmp') do windbg  -QY -c ".logopen /d;!analyze -
    v;q" -z %I

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 00.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 01.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 02.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 03.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 04.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 05.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 06.dmp

    C:\dumps>windbg  -QY -c ".logopen /d;!analyze -v;q" -z 07.dmp

    C:\dumps>dir /b
    00.dmp
    00.dmp.log
    01.dmp
    01.dmp.log
    02.dmp
    02.dmp.log
    03.dmp
    03.dmp.log
    04.dmp
    04.dmp.log
    05.dmp
    05.dmp.log
    06.dmp
    06.dmp.log
    07.dmp
    07.dmp.log
    autoanalyzedumps.bat

    C:\dumps>

    Friday, August 2, 2013 12:41 PM
  • Thanks everyone for all your great advise with this issue.
    Sunday, August 4, 2013 7:02 AM
  • What if I want to execute two or more commands? For instance !symfix !analize -v; is there a need to put comma or something else beetwen them?
    Thursday, April 4, 2019 7:01 AM
  • Use a semicolon.
    Thursday, April 4, 2019 3:29 PM