Subscribe to Windows IT Pro
January 09, 2000 12:00 AM

How do I include freehand comments in a batch file without using REM statements?

Windows IT Pro
InstantDoc ID #13453
Rating: (1)

[Editor’s Note: Some or all of the following FAQ text was submitted by readers, Royce Williams and Noel Casey.]

A. When Windows NT batch file processing encounters the goto command, the process ignores lines in the batch file until it finds the appropriate goto label.


@echo off<br>
goto Begin<br><br>
BATCHFILE.BAT v1.01 - does what batch files do<br>
written 09/09/1999 by Joe Programmer<br><br>
MODIFICATION HISTORY:<br><br>
v1.00 09/04/1999 jp<br>
initial version<br><br>
v1.02 09/09/1999 jp<br>
converted all dates in comments to<br>
four-digit years for Y2K compliance<br><br>
:Begin<br><...><br><br>
:End</...>

Another method, which works on Windows NT 4.0 and Windows 95, is to use a double colon, as follows.

@echo off<br>
echo Hello<br>
echo.<br>
:: This is equivalent to rem at the beginning of a line<br>
rem This is an equivalent statement to the line above<br>
:: This looks and reads better than rem<br>
:: That&#8217;s all<br>
echo Bye!

Related Content:

ARTICLE TOOLS

Comments
  • Cresma
    8 years ago
    Apr 06, 2004

    Goat is right; a single colon indicates the start of a label. A note on rem vs ::, the command processor processes the rem statement while :: is ignored.

  • Goat
    8 years ago
    Feb 03, 2004

    Not true, the single colon is seen as a label.

  • KENNETH
    9 years ago
    Jan 23, 2003

    The method of using double colons for REM statements is not necessary. Single colons are the same thing. The batch processor sees anything following the first colon as a comment.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.