Return to site

Comment in windows batch file

broken image

That way, the label is invalid but still treated as a label, and skipped (i.e. This method has the disadvantage that your batch file may 'accidently' really use the label to jump to.Īs Marc Stern points out in one of his MS-DOS batch files Tips & Tricks, this can be solved by using a double colon ( :: ) as the first characters of the comment line.

broken image

This means each comment line causes one extra reread of the batch file no problem when read from harddisk, but it may slow down batch file execution from slow floppy or network drives.Ī workaround I have seen many times (back in the old days, when I was young, and dinosaurs roamed the Earth and harddisks were 20MB) is to convert the comment line to a label by starting the line with a colon ( : ).ĬOMMAND.COM skips labels it doesn't have to jump to. If you have many lines REMed out, this may slow down COMMAND.COM's processing of the batch file.Īs you probably know, COMMAND.COM reads a batch file, executes one command line, reads the batch file again, executes the next command line, etcetera. Regardless of the programming or scripting language used, it is always a good idea to insert comments in scripts, explaining what the next lines or block of code is trying to accomplish, how and/or why.Ĭomments in batch files are usually placed in lines starting with REM (REMarks).