REM – Windows CMD Command
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
For example: @ECHO OFF :: :: First comment REM Second comment REM 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 important limitation of this is that as a label it can only be used at the beginning of the line.
1 2 3 4 5 6 7 8 |
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 can even include - | > characters :START |
Comments within bracketed code blocks.
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:
1 2 3 4 5 6 7 8 |
( Echo This example will fail :: some comment ) ( :NormalLabel & Echo this will not be executed. :SecondaryLine & Echo This will be executed. ) |
When working within parentheses/brackets it is safer to use REM for all comment lines.
Bugs
A comment like the examples below will be interpreted as a command and will produce a fatal error:
::%~
or
REM %~
or similarly with a variable
set var=demo
rem %var:=
or
rem %var:*=
There errors will terminate all further batch processing and return an error message:
The following usage of the path operator in batch-parameter substitution is invalid: %~
This behaviour is a result of the batch parsing rules used by CMD.EXE and so is unlikely to ever change.
A REM comment can be significantly slower to process than ::
In Windows NT 4 the REM comment would incorrectly reset the %errorlevel% to 0.
To avoid these issues, make sure your comments do not contain % chars or any redirection operators.
Registry Comments
Within a registry .REG file comments can be preceded by ;
1 2 3 4 5 |
; ; 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.
1 2 3 4 5 6 7 8 9 10 |
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> |
REM does not set or clear the Errorlevel.
REM is an internal command.
Thank you, I have just been searching for information approximately this topic for a long time and yours is the greatest I’ve came upon till now. But, what about the bottom line? Are you certain in regards to the source?