Comments with REM
REM can remark a complete line, also a multiline caret at the line end, if it's not the end of the first token.
REM This is a comment, the caret is ignored^
echo This line is printed
echo This line is part of the remark
Comments with ::
:: always executes a line end caret.
:: This is also a comment^
echo This line is also a comment
Labels and also the comment label
:: have a special logic in parenthesis blocks.
They span always two lines SO: goto command not working.
So they are not recommended for parenthesis blocks, as they are often the cause for syntax errors.
ECHO ON a
REM line is shown, but not a line commented with
Both can't really comment out the rest of the line, so a simple
%~ will cause a syntax error.
REM This comment will result in an error %~ ...
But REM is able to stop the batch parser at an early phase, even before the special character phase is done.
REM This caret ^ is visible
Comments with percent signs
There exists a comment style with percent signs.
In reallity these are variables but they are expanded to nothing.
But the advantage is that they can be placed in the same line, even without
The equal sign ensures, that such a variable can't exists.
set "var=3" %= This is a comment in the same line=%
The percent style is recommended for batch macros, as it doesn't change the runtime behaviour, as the comment will be removed when the macro is defined.
%=Start of code=% ^