I don't beleive I have ever run across this before, but I am testing a script so I find myself commenting out sections and lines. I commented out the last line of a FOR loop just a few minutes ago and tested the replacement string above it... Here is a simple example of the problem:
Code: Select all
@Echo Off
FOR /F "tokens=1-2 delims= " %%a IN ("Test This") DO (
Echo.a = %%a
Echo.b = %%b
Echo.This Works
REM This Works
)
FOR /F "tokens=1-2 delims= " %%a IN ("Test This2") DO (
Echo a = %%a
Echo b = %%b
Echo This Works
:: This does NOT work
)
For the record I exclusively use :: for my comments as opposed to REM. With the exception of an interesting technique I picked up here to use %== Comment ==% for inline comments.
You can move that ) down a few lines and get an "incorrect Syntax" error instead of the error that this generates...
The :: comment syntax can be used anywhere else in the FOR loop, but it cannot be the last unblank line in the command block without generating an error.