title: Stop a batch file using another batch file?
body: <p>I have a batch file which starts a new batch file on a new cmd prompt using the following command:</p>
  
  <pre><code>C:\Windows\System32\cmd.exe /c "start mybatch.bat"
  </code></pre>
  
  <p>The <code>mybatch.bat</code> process keeps on running until someone stops it. When we close this batch file using the <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, it does the operation of collecting the coverage data and then comes out. After initiating the <code>mybatch</code> file I am doing some other process on the parent batch file and then I want to stop the <code>mybatch</code> file.</p>
  
  <p>I tried using <code>taskkill</code> for closing the process using the command in the parent batch file:</p>
  
  <pre><code>taskkill /fi "windowtitle eq c:\Windows\SYSTEM32\cmd.exe - mybatch.bat"
  </code></pre>
  
  <p>The problem here is that it stops the batch file forcefully not allowing it to run the coverage process which would have happened if I had used <kbd>Ctrl</kbd>+<kbd>C</kbd> manually. Any thoughts on how I could achieve stopping the mybatch file using the parent batch file?</p>
  
  <p>Everything is done using a batch file. Any help is highly appreciated.</p>
  
  <p>My main batch file looks something like:</p>
  
  <pre><code>start mybatch.bat
  REM do something like copying files, running tests, etc
  taskkill /fi "windowtitle eq c:\Windows\SYSTEM32\cmd.exe - mybatch.bat"
  </code></pre>
  
  <p>In the above code instead of doing <code>taskkill</code> what if I want to do <kbd>Ctrl</kbd>+<kbd>C</kbd> on the command prompt with windowtitle "c:\Windows\SYSTEM32\cmd.exe - mybatch.bat" using the main batch file. Is it possible?</p>