Stop command in midway and restart it.

Vitaminzed

Honorable
Feb 22, 2012
2
0
10,510
0
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!
 

Rusting In Peace

Distinguished
Jul 2, 2009
313
0
19,060
34
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.

Code:
<commandToRun>
ping 123.45.67.89 -n 1 -w 10000 > nul
taskkill /F /IM <commandToRun>
call <thisbatchfile>
 

Rusting In Peace

Distinguished
Jul 2, 2009
313
0
19,060
34


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
 
Thread starter Similar threads Forum Replies Date
B Apps General Discussion 2
B Apps General Discussion 2
N Apps General Discussion 4
S Apps General Discussion 4
ccoo84 Apps General Discussion 2
G Apps General Discussion 0
R Apps General Discussion 1
C Apps General Discussion 3
H Apps General Discussion 6
A Apps General Discussion 1
A Apps General Discussion 11
A Apps General Discussion 7
T Apps General Discussion 5
M Apps General Discussion 1
R Apps General Discussion 1
C Apps General Discussion 3
H Apps General Discussion 3
R Apps General Discussion 7
R Apps General Discussion 1
R Apps General Discussion 3

ASK THE COMMUNITY