<p>1.exe doesn't give enough time for me to launch the IDE and attach 1.exe to the debugger to break into.</p>

[{'answer_id': 75799, 'author': 'Clinton Pierce', 'author_id': 8173, 'author_profile': 'https://Stackoverflow.com/users/8173', 'pm_score': 0, 'selected': False, 'text': "<p>I assume you have the source to 1.exe (if you're debugging it), then just insert a statement near the beginning that will cause it to hang around long enough to attach a debugger.  ( getch() if you're desperate and it's not interactive. )</p>\n\n<p>After the attach, just skip to the next statement and let it go.</p>\n"}, {'answer_id': 75803, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 0, 'selected': False, 'text': '<p>You could put in some preprocessor commands for debug builds - just remember to build your release in release mode:</p>\n\n<pre><code>#ifdef DEBUG\nThread.Sleep(10000);\n#endif\n</code></pre>\n'}, {'answer_id': 75814, 'author': 'Alex Duggleby', 'author_id': 5790, 'author_profile': 'https://Stackoverflow.com/users/5790', 'pm_score': 3, 'selected': False, 'text': '<p>I would suggest taking the same approach as with NT services in this case. They will also start and usually not give you enough time to attach the debugger for the start-up routines.</p>\n\n<p>Details are described here: <a href="http://www.debuginfo.com/articles/debugstartup.html" rel="noreferrer">http://www.debuginfo.com/articles/debugstartup.html</a></p>\n\n<p>In short you add a registry entry for the second exe:</p>\n\n<blockquote>\n  <p>HKLM\\Software\\Microsoft\\Windows\n  NT\\CurrentVersion\\Image File Execution\n  Options\\2.exe   Debugger =\n  "c:\\progs\\msvs\\common7\\ide\\devenv.exe\n  /debugexe" (REG_SZ)</p>\n</blockquote>\n\n<p>Change the c:\\progrs\\msms\\ to match your settings.</p>\n\n<p>Hope that helps.</p>\n'}, {'answer_id': 75854, 'author': 'Steve Morgan', 'author_id': 5806, 'author_profile': 'https://Stackoverflow.com/users/5806', 'pm_score': 0, 'selected': False, 'text': '<p>How is 1.exe launched? If you can launch it using CreateProcess(), you can start the process in a suspended state, attach the debugger, then release the new process.</p>\n'}, {'answer_id': 75876, 'author': 'Michael Ratanapintha', 'author_id': 1879, 'author_profile': 'https://Stackoverflow.com/users/1879', 'pm_score': 0, 'selected': False, 'text': '<p>If you are willing to consider a debugger other than Visual Studio, <a href="http://www.microsoft.com/whdc/devtools/debugging/install64bit.mspx" rel="nofollow noreferrer">WinDBG</a> can auto-debug child processes (native code only).</p>\n'}, {'answer_id': 76367, 'author': 'Alex Reitbort', 'author_id': 11525, 'author_profile': 'https://Stackoverflow.com/users/11525', 'pm_score': 0, 'selected': False, 'text': '<p>You did not mention what language you are using. But if you using C# or VB.NET you can add Debug.Break() or Stop to trigger the prompt to attach debugger to the process.</p>\n\n<p>Or as mentioned above just use something like Console.Readline() or MessageBox.Show() to pause starting of process untill you can attach debugger to it.</p>\n'}]
['https://Stackoverflow.com/questions/75763', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13432/']