Skip to content

Batch Script Comments

How to add comments in Batch Script using the Rem and :: statements for better script readability and maintenance.

Batch Script Comments

Comments in Batch Script can be made in two ways:

  • using the Rem statement
  • using the :: statement

Comments Using the Rem Statement

Comments in Batch Script can be made using the Rem command.

Any text which follows the Rem statement will be treated as comments and will not be executed.

Rem Examplebatch
Rem My comment

where My comment is the comment that needs to be added.

For example, in the following snippet, the Rem command is used to describe what the program does. Notice that the line with the Rem statement will not be executed.

HelloWorld.batbatch
@echo off 
Rem This program displays Hello World 
set message=Hello World 
echo %message%
Outputplaintext
Hello World

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.

:: Examplebatch
:: My comment

where My comment is the comment that needs to be added.

Like the Rem command, the :: command is used to describe what the program does.

HelloWorld.batbatch
@echo off 
:: This program displays Hello World 
set message=Hello World 
echo %message%
Outputplaintext
Hello World
Navigation