In a batch file
REM at the start of a line signifies a comment or REMARK
alternatively adding :: at
the start of a line has a similar effect
For example:
@ECHO OFF
::
:: First comment
::
REM Second comment
REM
::
Although you can use rem without a comment to add vertical spacing to a batch
file, you can also use completely blank lines. The blank lines are ignored when processing
the batch program.
The double-colon is not documented as a comment command, it is a special case of a CALL label that acts like a comment. The pro's and cons of each method are listed below.
Bugs
There are problems
using a :: comment within an IF or FOR code bracket
e.g.
@echo off
FOR /L %%i IN (1,1,10) Do (
Echo before comment
:: Some comment
Echo after comment
)
The above will return the error :: was unexpected at this time.
In Windows 2000 and XP a comment like
::%~
or
REM %~ will
be interpreted giving the error:
The following usage of the path operator in batch-parameter substitution is
invalid: %~
In Windows NT 4 the REM command would incorrectly reset the %errorlevel% to 0
The bottom line on this is that you must test your comments to be sure they will be ignored as you expect.
Registry Comments
Within a registry
file comments can be preceded by "; "
e.g.
;
; Turn the NUMLOCK on at login
;
[HKEY_CURRENT_USER\Control Panel\Keyboard]
"InitialKeyboardIndicators"="2"
FTP Comments
There is no valid comment character for FTP but you can cheat
by escaping to the shell and running REM
e.g.
C:\WORK>type ftpscript
!REM This is a remark
bye
C:\WORK>ftp -s:ftpscript
ftp> !REM This is a remark
ftp> bye
C:\WORK>
"First they ignore you, Then they laugh at you, Then they fight you, Then you win" - Gandhi
Equivalent BASH command:
### - Comment / Remark