3

As the title says what parameters would you use in a batch file to continually execute a command e.g.

start notepad loop

2

2 Answers 2

6

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

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

If you're using that in a batch file, use

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

instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this. It works perfectly. Could you explain the syntax to make the answer even better ?
4

Use goto:

:loop
start /wait notepad
goto loop

Note that I have used start /wait here. If you don't do that, your batch file won't wait for notepad to exit, and you'll start a zillion notepads and probably eventually crash.

5 Comments

Sorry didnt work, loaded notepad, batch stopped, so I quite notepad and it close the batch
My apologies, I had the label syntax backwards. A label is :loop as now shown above (I edited my answer).
Thats it, should of spotted the typo myself!
Can you make it wait 5 seconds and then loop?
@James: There are several techniques for doing that here: stackoverflow.com/questions/348849/pause-in-batch-file.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.