Stop command in midway and restart it.

Hi guys! Here's what I need done. I need a batch file to run a command; end it after 10 seconds; and restart the command in an endless loop. Thanks for any help!
4
answers
Last reply
More about stop command midway restart
  1. Try using something like the following.

    Replace <commandToRun> with what you actually want to execute and <thisbatchfile> as the name. The ping command is just pinging an address that doesn't exist with a 10 second timeout.

    
    <commandToRun>
    ping 123.45.67.89 -n 1 -w 10000 > nul
    taskkill /F /IM <commandToRun>
    call <thisbatchfile>
    
  2. This won't work, because the <commandToRun> is a never ending command.
  3. What exactly is a "never ending command"? If you kill the process, it ends it.
  4. Vitaminzed said:
    This won't work, because the <commandToRun> is a never ending command.


    You might have viewed my reply before I edited it. Initially I had forgotten the taskkill statement so in that scenario then you would have just had n running instances of the command.

    But with the taskkill statement and the /F flag then the process will be killed off
Ask a new question

Read More

Programming Command Prompt Apps