Reputation: 913
How can I Save Output of a command in WinDbg to a Text File?
Upvotes: 56
Views: 38577
Reputation: 310
To send the output of a specific command to a file, go and get Tee, (I use Tee.bat), put it into a directory covered by the Windows PATH
environment variable (or add the directory you've put it in). Then use the following syntax from the WinDbg GUI to send the output of a command to a file
.shell -ci "<command>" tee <file>
.shell -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log
There's an undocumented !!
abbreviation of .shell
. So you could just do:
!! -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log
Background
You can run shell commands in the WinDbg GUI. The syntax is:
.shell [Options] [ShellCommand]
.shell -i InFile [-o OutFile [-e ErrFile]] [Options] ShellCommand
Here I found the solution to send the command output to the clipboard.
.shell -ci "<command>" clip
If you can send the output to clip
, shouldn't it be possible to send it to a file, like so?
.shell -ci "<command>" > <file>
.shell -ci "!gcroot 000002b56c414750" > c:\path\out_01.log
Would be nice, but it does not work. In the MS docs I found this example.
.shell -ci "!process 0 7" perl.exe parsemyoutput.pl
So it is possible to send the output to an application. Just like the above example using clip
. And that's where Tee came in. But you could use any other script or .exe which takes the output and stores it in a file or another place.
Upvotes: 0
Reputation: 394129
You can also do this from the WinDbg gui 'Edit>Write Window Text To File...' if you find that easier.
Upvotes: 16
Reputation: 27499
Start WinDbg from the command line using the -logo option:
windbg.exe -logo logfile.txt
That will get everything done logged to the file specified. You can find more details of the command line options here.
Or, if you are already in a debugging session, you can use the .logopen command to start logging. For more info on this command see here
Or you can click edit->Open/Close log file in the WinDbg GUI.
More info on log files is here.
Upvotes: 61
Reputation: 361
You can use .logopen , all of the commands you input and response from windbg will be logged, and then use .logclose to flush the data into
Upvotes: 35