How to cycle a command in batch files

As the header says, what parameters would you use in a batch file to continuously execute a command, for example.

run notepad cycle

+3
source share
2 answers

Another option in one line (which will also work from the command line):

for /l %x in (1,0,2) do (start /wait notepad)

If you use this in a batch file, use

for /l %%x in (1,0,2) do (start /wait notepad)

instead.

+6
source

Use goto:

:loop
start /wait notepad
goto loop

Please note that here I used start /wait. If you do not, your batch file will not wait for an exit notepad, and you will begin to create millions of notebooks and, possibly, will eventually work.

+3
source

All Articles