I have an old MS DOS computer running DOS 7.10 (ver command gives: windows 98 ver 4.10.2222). I have to make a batch script that basically runs a command 10 or whatever times. I tried using the for command but it gave me ILLEGAL Command For So now I have:
@ECHO off
SET COUNT=0
:MyLoop
IF "%COUNT%" == "10" GOTO EndLoop
ECHO %COUNT%
SET /a COUNT+=1
:EndLoop
ECHO done
However, this gives me an infinite loop of 0 as if set command is not working. The command DOES work in CMD in windows 10 though. Can anyone suggest what I am doing wrong? Or a way to implement a for loop in DOS 7 batch file.
set /a count+=1
that's the problem. Try expanding it toset /a count=%count%+1
– SomethingDarkFOR %I IN (1 2 3 4 5) ...
– Jeff Zeitlinset /A
; neither isfor /L
. So you have to use eitherfor %%I in (1 2 3 ...) do
, or, if you want to use agoto
loop,set "COUNT=%COUNT%_"
andif "%COUNT%"=="___..."
. – aschipflcmd.exe
as command interpreter on compatibility withcommand.com
. Start the batch file on newer Windows withsetlocal DisableExtensions
andcmd.exe
interprets the batch file likecommand.com
.cmd /?
outputs (most) commands affected by enabled/disabled command extensions. The individual help of each affected command explains which features/options require enabled command extensions. Once a batch file is running on newer Windows with disabled command extensions, it's time for testing it on MS-DOS or Windows 95/98. – Mofi