title: Run DOS Command for a Time Limit
body: <p>I want to perform the following operations.</p>
  
  <ol>
  <li>Read 1 word at a time from an input file consisting of many words.</li>
  <li>Pass this word as an argument to another command line based application.</li>
  <li>Run that application for a fixed amount of time, say 10 seconds.</li>
  <li>Abort the execution of the application if it is still running after 10 seconds and go back, pick the next word from the input file and repeat steps 1 to 3.</li>
  </ol>
  
  <p>Here is what I have written though it does not achieve exactly what I want it to:</p>
  
  <pre><code>@echo off
  for /f %%i in ('type input.txt') do call:Routine %%i
  
  :Routine
  set app="myApp.exe"
  set limit=60
  
  %app% %1
  goto Delay
  
  :Delay
  ping localhost -n %limit% &gt; nul
  </code></pre>
  
  <p>The above script will introduce the delay after the execution of myApp has completed. However, I want it to run myApp.exe for not more than 10 seconds, if it does, then abort the application using taskkill and move on to the next word from the input file.</p>
  
  <p>I searched for a solution online and came across this:</p>
  
  <p><a href="http://www.tech-archive.net/Archive/WinXP/microsoft.public.windowsxp.general/2006-04/msg03609.html" rel="nofollow">http://www.tech-archive.net/Archive/WinXP/microsoft.public.windowsxp.general/2006-04/msg03609.html</a></p>
  
  <p>Though it does not answer my query exactly, I would like to make my code do something similar.</p>
  
  <p>Thanks.</p>