I want to perform an operation multiple times from a DOS window. Common sense tells me that a DOS FOR loop should be able to handle this. Sure enough, if I want to execute, say, myProg.exe
, I can open a command window and use:
C:\> FOR %i in (1 2 3) DO myProg.exe
Easy.
But what if I want to execute myProg.exe
1000 times? I want to specify a range in the FOR loop, but I'm having trouble seeing how to do this.
Intuitively, it seems like I should be able to do something like one of the following:
C:\> FOR %i in (1 to 1000) DO myProg.exe
C:\> FOR %i in (1-1000) DO myProg.exe
But, of course, this doesn't work. The FOR loop interprets the list as 3 tokens and 1 token, respectively, so myProg.exe
is only executed 3 times and 1 time, respectively.
Batch File Solution
It'd probably be easy to write some sort of batch (.bat) file:
SET COUNT=0
:MyLoop
IF "%COUNT%" == "1000" GOTO EndLoop
myProg.exe
SET /A COUNT+=1
GOTO MyLoop
:EndLoop
But isn't there an easy way to do this from the command line?