title: Kill Process and each child processes opened by the parent process (Like 'TaskKill /F /T' command)
body: <p>I have an SFX <code>WinRAR</code> autoxtraible file which runs a textfile using notepad.exe process, and the SFX file waits to receive an exitcode of notepad.exe to finish the SFX execution.</p>
  
  <p>I would like to do a <code>treekill</code>, kill all the processes openen by the SFX file, or in other words, I would like to reproduce this Batch command, in <code>.NET</code>:</p>
  
  <blockquote>
    <p>/t   : Specifies to terminate all child processes along with the
    parent process, commonly known as a tree kill.</p>
  </blockquote>
  
  <pre><code>Taskkill /F /T /IM "SFX file.exe"
  </code></pre>
  
  <p>To kill a process I do this, in <code>VBNET</code>:</p>
  
  <pre class="lang-vb prettyprint-override"><code>''' &lt;summary&gt;
  ''' Kill a process specifying the process name.
  ''' &lt;/summary&gt;
  Private Sub Kill_Process(ByVal ProcessName As String,
                           Optional ByVal Recursive As Boolean = True)
  
      ProcessName = If(ProcessName.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase),
                       ProcessName.Substring(0, ProcessName.LastIndexOf(".")),
                       ProcessName)
  
      For Each p As Process In Process.GetProcessesByName(ProcessName)
          p.Kill()
          If Not Recursive Then Exit For
      Next p
  
  End Sub
  </code></pre>
  
  <p>Now, In <code>C#</code> or <code>VBNET</code> how I could identify the child processes opened by the SFX to kill them all at once?</p>