 <p>You don't. And you're mixing up pretty unrelated things.</p> <h2>PageHeap</h2> <p><strong>To enable the heap verification</strong> ("PageHeap") you set the configuration you want using the GFlags utility, either using the GUI or passing it the approporiate command-line arguments (See <a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff549561(v=vs.85).aspx" rel="nofollow" title="GFlags and PageHeap">GFlags and PageHeap</a>). Either way, this setting it global for all binaries with the name you define.</p> <h2>Debugging</h2> <p>To run the program under the debugger each and every time it starts you'd probably want to use the Debugger setting under Image File Execution Options. You can set it too using GFlags. Tick the <em>Debugger</em> checkbox in the <em>Image File</em> tab (after specifying the EXE name and hitting tab) and enter the path to the debugger.</p> <p>The way this mechanism works is that (somewhere) inside <code>CreateProcess</code> there's a test whether or not IFEO\Debugger is set for the program you're trying to run, and if it is set, whatever set in the Debugger value is executed **and it is passed the original command line*.</p> <p>So if you set</p> <pre><code>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe\Debugger </code></pre> <p>to be <code>C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe</code> and then try to execute <code>C:\Users\d_blk\Desktop\foo.exe -param 1 -param 2</code>, Windows runs </p> <pre><code>C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe C:\Users\d_blk\Desktop\foo.exe -param 1 -param 2 </code></pre> <p>and WinDbg passes everything after <code>foo.exe</code> to the target program (as noted <a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff561306(v=vs.85).aspx" rel="nofollow" title="WinDbg Command-Line Options">here</a>).</p> <p>So you see, there's no need to set the command-line arguments to the program you're debugging anywhere but wherever you're running it.</p> <p>The only connection between PageHeap and IFEO\Debugger is that you can control both of them through the GFlags utility.</p> <h3>Caveats</h3> <p>Note all the usual caveats for using IFEO\Debugger. For example:</p> <ul> <li>The caller gets from <code>CreateProcess</code> a handle to WinDbg, not the target process (and process ID, etc.).</li> <li>Any information in a non-default <code>STARTUPINFO</code> argument applies to WinDbg, not the target process. Same for <code>lpEnvironment</code> I guess.</li> </ul> <p>If that doesn't affect you great. If it does, an alternative might be adding an unhandled exception at the beginning of your program, and setting WinDbg as the post-mortem debugger (<code>AeDebug</code>)</p>