batch-file Comments in Batch Files Using Variables as Comments


It is also possible to use variables as comments. This can be useful to conditionally prevent commands being executed:

@echo off 
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 with update as a parameter.