DEV Community

Victor James
Victor James

Posted on • Originally published at windowscmd.com on

REM Command: Records Commands in a Batch File

REM

REM

The REM windows command-line tool is to record comments in a batch file. To know more about this command, read this article further.

CMD Line

CMD Line is a ** text-based interface** that transfers the command from the user to the OS.

CLI-Command Line Interpreter

The command-line interpreter (CLI) for windows is CMD.EXE. Also, you can use PowerShell, which can automate many system administration tasks and these tasks are not approachable in command prompt. With the help of the CLI, you can communicate with your system by typing the text in commands. As a result, your system answers to the text that you have typed previously, and then the user can proceed with the following command line that shows up.

To open the Run command Window.

Run command window helps you to run programs, open the files and folders. And there are several ways to open up the run command dialog box. This run command box is helpful for you to head straight to the destined program quickly.

By using the Keyboard shortcut Key:

WINDOWS+R

One of the most commonly used methods is the shortcut key method. Also, this method is in all versions of Windows. It would help if you pressed the Windows+ R ** ** key concurrently to open the Run command dialog box.

Run command box
Run command box

What does the REM windows command do?

The REM windows command-line utility is to record comments in a script, batch file. It will add vertical spacing if no comment is mentioned. This command is internal

we can use this command everywhere in the command line.

REM at the start of the line indicates a comment in the batch file.

  • Another method includes :: ** in the line’s starting, which has a relative impact on the REM. The ** secondary colon is not valid as a name in the double-colon, and it is interpreted as a label.

For instance


@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

Enter fullscreen mode Exit fullscreen mode
  • Without Echo off, we should not give the double colon ** ** as it is a command too. As a result, it will display if you execute it as a batch file without Echo Off.

Multiple Line comments

  • A method to add a large multi-line block of comment test is by using plain text and a goto command.

@Echo OFF
Goto :START
Description can go here
which can even include - | > characters

:START

Enter fullscreen mode Exit fullscreen mode
  • We should not give GOTO commands ** inside brackets**. We can manage those cases by giving it inside the brackets like,

(
  Echo the lines below are commented
  Rem/||(
    some comment text that will work within brackets.
    The REM command always evaluates to TRUE so these
    lines will never be executed.
  )
)

Enter fullscreen mode Exit fullscreen mode

Errors

  • A message will appear like

The following usage of the path operator in batch-parameter substitution is invalid: %~

This error message shows if you interpret commands like


::%~
or
REM %~

Enter fullscreen mode Exit fullscreen mode

In order to dodge this issue, do not use % in comments.

Inline comments

You can also add a line in the middle in the batch variables, spaces, and punctuations as it does not exist. Start it with = and end it with = sign like,


@Echo off
Echo This is an example of an %= Inline Comment =% in the middle of a line.

Enter fullscreen mode Exit fullscreen mode

Verdict

This article will let you learn about the REM command. For more information about windows, commands, visit our homepage. Leave your valuable comments in the comment section.

Related Articles

The post REM Command: Records Commands in a Batch File -RTP appeared first on Windows Commands- SS64 Commands.

Discussion (0)