To comment on the same line as the code you can use &::
or &rem
. You can also use &&
or ||
to replace &
.
Example :
@echo off
echo This is a test &::This is a comment
echo This is another test &rem This is another comment
pause
A curiosity: SET
command allows limited inline comments without &rem
:
set "varname=varvalue" limited inline comment here
Limitations:
set "varname=varvalue"
or set "varname="
,cmd
poisonous characters | < > &
must be properly escaped as ^| ^< ^> ^&
,( )
must be properly escaped as ^( ^)
within a bracketed code block.