batch-file Comments in Batch Files Comment on the code's line


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

A curiosity: SET command allows limited inline comments without &rem:

set "varname=varvalue"    limited inline comment here


  • syntax with double quotes set "varname=varvalue" or set "varname=",
  • an inline comment may not contain any double quote,
  • any cmd poisonous characters | < > & must be properly escaped as ^| ^< ^> ^&,
  • parentheses ( ) must be properly escaped as ^( ^) within a bracketed code block.