The REM command in Windows Command Prompt (CMD) is used to record comments or remarks within batch files or scripts. It does not affect the execution of the script and serves as a way to document the purpose or operation of specific lines of code, making scripts easier to understand and maintain. This command is most effective in large or complex batch files where explanations of specific operations are crucial for future reference or for other users who might interact with the script.


The basic syntax for the REM command is:

REM [comment]
  • [comment]: This is the text of the comment. It is not executed as part of the batch file but is included for explanatory purposes or documentation.


The REM command does not have options or flags. It is purely used for adding comments, and thus, its functionality is straightforward with no variations in behavior.


  1. Basic Usage:

    REM This is a simple comment explaining what the next line does
    COPY file1.txt file2.txt
  2. Using REM at the start of a batch file:

    REM Script to backup files
    REM Created on 01-Jan-2023
    XCOPY C:\source D:\backup /S /E /H
  3. Using REM to disable a code line temporarily:

    REM The following line has been disabled for debugging purposes
    REM DEL C:\temp\file.txt

Common Issues

  • Visibility in Command Prompt: When running batch files, comments are by default not visible in the command prompt. This is generally not an issue but may confuse beginners who expect to see their comments during execution.
  • Misuse of REM for control flow: Some users mistakenly attempt to use REM as a way to control the execution flow of a batch file. REM is only for comments and does not influence command execution.


REM can be used effectively in conjunction with any CMD command to enhance the readability and maintainability of scripts. Below is an example of how REM can be used in a complex script:

REM Initialize the backup process
SET source=C:\source
SET destination=D:\backup

REM Copying files
XCOPY %source% %destination% /S /E /H

REM End of script
ECHO Backup completed successfully!

In this script, REM comments are used to explain each section of the script, making it clear what each part does.

  • ECHO: Used to display messages or turn command echoing on or off. It is often used for debugging or script outputs but does not serve the same documentary purpose as REM.
  • Batch file scripting commands: While not specific commands, the general scripting capabilities within CMD (like IF, FOR, GOTO, etc.) are often used alongside REM for crafting complex scripts.

For further reading and more details, consult the official Microsoft documentation for batch files and scripting in Windows CMD.