Debugging application startup when you don’t directly launch the app

Out of the blue yesterday an internal MS architect called me in my office (which rarely happens.) They needed to debug a second instance of Windows Media Player which crashed when launched within Internet Explorer.  The good old “Attach to process” debugger trip wouldn’t work, since Media Player faulted before they could attach to it.

Reaching way back into my bag of tricks, I recalled the “Image File Execution Options” trick. By setting a registry key, you can cause Windows to launch a different executable than the original program. In this case, you tell Windows to start the debugger of your choice, with the name of the original executable passed as an argument to the debugger.

This trick is mainly used for debugging services, but comes in handy in other cases as well. After a day of fighting the version control system and test scripts, it sure felt good to have done at least one useful thing.