Are you running the application with windbg enabled or are you debugging JIT? If the latter (i.e. you rely on tuning in HKLM \ Softare \ Microsoft \ Windows NT \ AEDebug \ Debugger), simply change the value of the Debugger key to use the -c command to run the command after the debugger joins.
Assuming the first, you can try to start the debug server using a named pipe or tcp (using the .server command). You can then write a console application to start the cdb instance as a client, to connect to the aforementioned windbg server, and have the parse stdout application until you see the debugger prompt. You can then effectively automate your debugging session from this point. Thus, it reduces the parsing exercise, possibly wrapped in FSM, depending on how complex you want to get.
source share