Rem / :: / ;

Index
Records comments (remarks) in batch files and Config.sys. These are ignored during the execution of the program.

Syntax:

REM [comment]

In Config.sys only:
; [comment]

In batch files (including Autoexec.bat) only:
:: [comment]

Notes:

  1. In Config.sys a semicolon (;) has the same effect as REM. Batch files do not recognize the semicolon and will generally cause an error message about a bad command.

  2. In batch files a double colon (::) has the same effect as REM.
    Actually, the double colon creates a label (see GOTO) which has a colon as the first character. Although Command.com recognizes this as a label, GOTO doesn't, and so there is no chance of confusing a label and remark.

  3. REM has a major limitation (see below) and, because of this, it is preferable to use the alternatives of a semicolon (;) in Config.sys and double colon (::) in batch files).

Limitations

When parsing a batch file, Command.com does not simply skip any lines beginning with "REM". Instead, it seems to parse the line for recognized commands/files/whatever and then take no action if the line begins with REM. This is not particularly efficient and a large number of REM statements in a batch file can noticeably slow down its execution.

A much more serious problem with REM occurs if the line contains a pipe (|) or redirection (<, >, >>) symbol: everything up to the symbol is ignored BUT the symbol itself and everything following is interpreted as a command line entry - but without the safeguard of syntax checking. This can lead to all sorts of problems - especially when REM is used to temporarily inactivate lines in a batch file. A simple illustration of this can be given by the following:

In a batch file the line:
Echo. | date
pipes an <Enter> to DATE, causing it to display the date and return to the command prompt.
One would expect that preceeding this command with REM whould cause the command to simply be ignored - but only the "Echo." part is. Command.com tries to process the "| date" part and the system hangs waiting for input from a non-existant preceeding command. The only remedy is to close the Dos window or reboot.

Note that having the line:
|date
causes Command.com to simply respond with the message "Syntax error" and return to the prompt.

The way to avoid such problems is to use the double colon (::) rather than REM.

Incidentally, entering either REM echo. | date or :: echo. | date directly on the command line (rather than in a batch file) not only causes Command.com to hang, but the only way to close the Window is with Ctrl-Alt-Del. Not that it makes much sense to enter such a command in the first place.

Tricks

The REM command is widely used to temporarily disable commands in Config.sys and batch files (but better to use :: or ; - see "Limitations" above).

Example:

To include an explanatory comment in Config.sys before the COUNTRY command:
;set country code to France
COUNTRY=033

or (if you must!):
REM set country code to France
COUNTRY=033

File Details:

Internal


This page last revised:
December 9, 1999.