title: How to terminate all [grand]child processes using C# on WXP (and newer MSWindows)
body: <p><strong>Question: How can I determine all processes in the child's <em>Process Tree</em> to kill them?</strong></p>
  
  <p>I have an application, written in C# that will:</p>
  
  <ol>
  <li>Get a set of data from the server,</li>
  <li>Spawn a 3rd party utility to process the data, then</li>
  <li>Return the results to the server.</li>
  </ol>
  
  <p>This is working fine.  But since a run consumes <em>a lot</em> of CPU and <em>may</em> take as long as an hour, I want to add the ability to have my app terminate its child processes.</p>
  
  <p>Some issues that make the simple solutions I've found elsewhere are:</p>
  
  <ul>
  <li>My app's child process "A" (InstallAnywhere EXE I think) spawns the real processing app "B" (a <em>java.exe</em>), which in turns spawns more children "C1".."Cn" (<em>most</em> of which are also written in Java).</li>
  <li>There will likely be <em>multiple copies</em> of my application (and hence, multiple sets of its children) running on the same machine.</li>
  <li>The child process is not in my control so there might be some "D" processes in the future.</li>
  <li>My application must run on 32-bit <em>and</em> 64-bit versions of MSWindows.</li>
  </ul>
  
  <p>On the plus side there is no issue of data loss, a "clean" shutdown doesn't matter as long as the processes end fairly quickly.</p>