Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/future4tech/public_html/wp-includes/functions.php on line 6114
REM – Windows CMD Command - Future4Tech

REM – Windows CMD Command

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

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.

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:

(
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 ;

;
; 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>

REM does not set or clear the Errorlevel.
REM is an internal command.

You may also like...

1 Response

  1. zoritoler imol says:

    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?

Leave a Reply

Your email address will not be published. Required fields are marked *


Notice: ob_end_flush(): Failed to send buffer of zlib output compression (0) in /home/future4tech/public_html/wp-includes/functions.php on line 5464