Search notes:

cmd.exe - rem

Usage of rem

rem can be used to add comment lines to batch files.
@echo off

rem This is a comment

echo the date is rem foo
date /t 
Github repository about-cmd.exe, path: /commands/rem/basic.bat

rem is a command

rem is a «real» built-in command.
This can be demonstrated with the following simple batch file:
@rem /?
@echo hello world && rem because rem is a command, in can be put in a command series with the ampersand
Github repository about-cmd.exe, path: /commands/rem/built-in.bat
When executed, the batch file prints:
Records comments (remarks) in a batch file or CONFIG.SYS.

REM [comment]

Using double colons

An unofficial (and sometimes problematic) way to comment lines is to use double colons (::) because it might be visually easier to read.
@echo off

rem   This is a real comment

echo  One

::    These lines are not interpreted/parsed and
::    thus might serve as comments.

echo  Two
Github repository about-cmd.exe, path: /commands/rem/double-colons.bat
A particular problem of :: occurs when used within ( … ):
@echo off

if exist double-colons-problem.bat (

   rem Notify the user that double-colon-problem.bat was found
   echo The file double-colons-problem.bat was found

) else (

   echo The file double-colons-problem.bat was not found

   :: This «comment» causes the error «) was unexpected at this time.»
)
Github repository about-cmd.exe, path: /commands/rem/double-colons-problem.bat

See also

cmd.exe: Built-in commands

Index