title: timeout or close when process is finished
body: <p>I have a <code>X.exe</code> program that takes about 2-6 hours to finish. Exact time is unknown, but I'd like to implement a threshold of 6.5 or 7 hours. If this program does not return any value by this amount of time, it will be killed. How do I implement this using batch <code>*.bat</code> files?</p>
  
  <p>Here is what I had so far: a timer <code>bat1.bat</code> and an actual <code>bat2.bat</code>. </p>
  
  <p>bat1.bat:</p>
  
  <pre><code>start cmd /C bat2.bat &amp; timeout /t 25200 &amp; taskkill /im X.exe /f
  </code></pre>
  
  <p>bat2.bat:</p>
  
  <pre><code>cd blah
  bat1.bat
  </code></pre>
  
  <p>The problem with this approach is that only after 25200 seconds (or 7 hours) the timer will be stopped, and it won't be terminated before that limit. How do I tell the computer that if the program <code>X.exe</code> is finished then don't wait anymore?</p>
  
  <p>Any help is appreciated!</p>