House
House

Reputation: 3496

WinDbg environmental variables

When using WinDbg to debug an executable, is there a way to specify a batch script to run before debugging starts to set up environmental variables for the debug session?

I'm attempting to mimic an automated test environment where this executable will run. The variables contain information like what the current build number is, where the results directory is and where the 3rd party tools directory is located. I could hard-code these into the application for my own testing, but that's ugly :).

This is of course on a Windows OS, and I would rather not use a different debugger.

If WinDbg doesn't support this directly, what is the best way to achieve this functionality?

Upvotes: 2

Views: 3316

Answers (1)

bk1e
bk1e

Reputation: 24338

WinDbg's -o option causes it to automatically attach to all child processes, which is useful for debugging a program that is launched from another program. If you run windbg -o cmd.exe /c myscript.bat, WinDbg will debug cmd.exe (which you can skip over) as well as every child process spawned by that instance of cmd.exe. This might be annoying if the batch file runs a lot of other commands before running the one that you want to debug, but the sx* commands (e.g. sxn ibp; sxe ld:mymodule) ought to be able to reduce the annoyance.

Another approach is to use the Image File Execution Options registry key to attach WinDbg (or cdb/ntsd) whenever your EXE is launched.

Upvotes: 5

Related Questions