CMD Master
Back to Blog
Arnošt Havelka

How to Comment with REM

Add notes to your scripts that the computer ignores — but you'll thank yourself later.

Start Interactive Lesson
How to Comment with REM

In the Windows Command Shell, a comment is a line the computer completely ignores when running your script. It's a note for you (or future you). The magic word is REM, short for Remark.

Try the command

Write your first comment!

Build the command
Terminal
C:\Users\Student>REM This is my first comment

Step 1: REM in the Terminal

Type a REM line in CMD and watch what happens:

Terminal
C:\Users\Student>REM # My Comment

Notice: When you run REM directly in the terminal, the line is shown — it just doesn't do anything. In a .bat script, you can suppress that display with @REM.

Step 2: Silent Comments with @REM

The @ prefix tells CMD: "Don't echo this line." Combined with REM, you get a truly invisible comment.

Terminal
C:\Users\Student>@REM # This comment is silent

Tip: Be careful about wrapping variables in quotes inside REM lines — you can accidentally double-quote things if you're not careful. @REM is the recommended style in scripts.

Step 3: The :: Shorthand

Many batch pros use :: as a faster-to-type comment marker:

Terminal
C:\Users\Student>:: This also works as a comment

⚠️ Warning: :: can cause errors inside FOR loops or IF blocks. When in doubt, use @REM.

Step 4 — Project: Write a Commented Backup Script

Let's put it all together. Use the editor below to write (and simulate!) a fully commented batch file. Click ▶ Run to see the output, then ⬇ Download .bat to run it on your real machine.

Here is the same script for reference:

@echo off
@REM # ===================================
@REM # daily_backup.bat
@REM # Copies work files to backup drive
@REM # Run every morning!
@REM # ===================================

@REM # --- Step 1: Set variables ---
SET "SOURCE=demo-work"
SET "DEST=demo-backup"
IF NOT EXIST "%SOURCE%" MKDIR "%SOURCE%"
echo Quarterly report>"%SOURCE%\report.txt"

@REM # --- Step 2: Do the backup ---
echo Starting backup...
xcopy "%SOURCE%" "%DEST%" /s /e /i /y

@REM # --- Step 3: Confirm ---
echo Backup complete!
PAUSE

Knowledge Check

1 / 4

What does REM stand for?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Introduction to Batch Files

Automate your daily tasks.