Question

first post. I have an interesting request that has to do with batch files. I want to know if it's possible to code it so that the program that is launched with the bat file will terminate after a set amount of time, and then automatically restart, and then this just loops forever/until the program is exited.

anyone have any ideas?!

thanks!!

No correct solution

OTHER TIPS

Something like this should work:

:TOP
  START /b notepad.exe
  PING 127.0.0.1 -n 5 -w 1000 > nul
  TASKKILL /im notepad.exe
GOTO :TOP

The /b for start will fire up a command in the background. We use notepad.exe in this example.

The strange ping command is a trick to get windows to sleep. -n takes a repeat count (5 in this case) and -w is the time in milisecs between pings. So this will ping 5 times with 1 sec delay between. in other words, it will wait for 5 secs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top