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.
:: First comment
REM Second comment
Echo Hello REM This remark is displayed by echo
Echo Hello & REM This remark is ignored by echo
Copy work.xls backup.xls &:: We backed up the file
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 label that acts as a comment.
An alternative approach is to use plain text and a goto command to jump execution past the comments:
@Echo OFF Goto :START
Description can go here which may even include - | > characters :START
When labels are used as comments within a bracketed code block or FOR command, the command processor will expect (not unreasonably) that every label is followed by at least one command. (That way if you jump to the label it will have something to execute.) In fact the CMD shell will attempt to execute the second line even if it is formatted as a label:
echo This example will fail
:: some comment
:NormalLabel & echo this will not be executed
:SecondaryLine & echo This will be executed
When working within brackets it is probably safer to use REM for all comment lines.
In Windows 2000 and XP a comment like
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.
Within a registry .REG
file comments can be preceded by ;
; Turn the NUMLOCK on at login
There is no valid comment character for FTP but you can cheat
by escaping to the shell and running REM
!REM This is a remark
ftp> !REM This is a remark
REM is an internal command.
#Now stand in the place where you work,
Now face West
Think about the place where you live, Wonder why you haven't before# - REM 'Stand'
Powershell: # - Comment / Remark
Equivalent bash command: ### - Comment / Remark
© Copyright SS64.com 1999-2013
Some rights reserved