Em scripts cmd.exe, comentários são adicionados usando REM (ou @REM para desativar com força o eco).
rem This is a comment.
Embora não seja tecnicamente um prefixo de comentário, :: também pode ser usado da mesma maneira (define um rótulo "goto" que permanece sem uso):
:: This is a comment.
Caution:
When labels are used as comments within a bracketed code block or for command, the command processor expects every label to be followed by at least one command, so when a jump is made to the label it will have something to execute.
The
cmdshell will try to execute the second line even if it is formatted as a label (and this causes an error):( echo This example will fail :: some comment )When working within bracketed code blocks it is definitely safer to use
remfor all comment lines.
Fonte Uso de rótulos como comentários
Você também pode usar variáveis como comentários .
It is also possible to use variables as comments. This can be useful to conditionally prevent commands being executed:
@echo off setlocal if /i "%~1"=="update" (set _skip=) Else (set _skip=REM) %_skip% copy update.dat %_skip% echo Update applied ...When using the above code snippet in a batch file the lines beginning with
%_skip%are only executed if the batch file is called withupdateas a parameter.