Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I comment on the Windows command line?

People also ask

How do I comment in Windows script?

A batch file can be commented using either two colons :: or a REM command. The main difference is that the lines commented out using the REM command will be displayed during execution of the batch file (can be avoided by setting @echo off ) while the lines commented out using :: , won't be printed.

How do you comment out a line in a batch script?

Comments Using the :: Statement The other way to create comments in Batch Script is via the :: command. Any text which follows the :: statement will be treated as comments and will not be executed.

How do you comment in DOS?

During execution of a batch file, DOS will display (but not act on) comments which are entered on the line after the REM command. You cannot use separators in the comment except the space, tab, and comma. To keep DOS from interpreting commands in a comment line, enclose the command in quotes.

How do I comment multiple lines in a batch file?

Usage: COMMENT can only be used in batch files. Both COMMENT and ENDCOMMENT must be entered as the only commands on their respective lines, and cannot be included in a command group. The COMMENT command is useful for entering multiline comments without having to prefix each line with a REM.


The command you're looking for is rem, short for "remark".

There is also a shorthand version :: that some people use, and this sort of looks like # if you squint a bit and look at it sideways. I originally preferred that variant since I'm a bash-aholic and I'm still trying to forget the painful days of BASIC :-)

Unfortunately, there are situations where :: stuffs up the command line processor (such as within complex if or for statements) so I generally use rem nowadays. In any case, it's a hack, suborning the label infrastructure to make it look like a comment when it really isn't. For example, try replacing rem with :: in the following example and see how it works out:

if 1==1 (
    rem comment line 1
    echo 1 equals 1
    rem comment line 2
)

You should also keep in mind that rem is a command, so you can't just bang it at the end of a line like the # in bash. It has to go where a command would go. For example, only the second of these two will echo the single word hello:

echo hello rem a comment.
echo hello & rem a comment.

A comment is produced using the REM command which is short for "Remark".

REM Comment here...

Sometimes, it is convenient to add a comment to a command line. For that, you can use "&REM misc comment text" or, now that I know about it, "&:: misc comment text". For example:

REM SET Token="4C6F72656D20697073756D20646F6C6F" &REM This token is for localhost
SET Token="722073697420616D65742C20636F6E73" &REM This token is for production

This makes it easy to keep track of multiple sets of values when doing exploration, tests of concept, etc. This approach works because '&' introduces a new command on the same line.


It's "REM".

Example:

REM This is a comment

: this is one way to comment

As a result:

:: this will also work
:; so will this
:! and this
: ***** and so on ***** :
: // even this \\ :

Above styles work outside codeblocks, otherwise:

REM is another way to comment.