Sithu
Sithu

Reputation: 4862

Code block comment syntax in Windows batch script

Is there any syntax for multi-line code block comment in Windows batch script? I know REM and :: for line-by-line comment, but it is not efficient to comment a code block.

I'm looking for the block comment style like something below in PHP:

/*
This is multi-lines
block comment
*/

Upvotes: 1

Views: 6828

Answers (4)

ay0ks
ay0ks

Reputation: 73

Multiline comment without those nasty gotos, rems and ::

@break || (
 1 line
 2 line
 3 line
 4 line
 5 line
 ...
)

EDIT: As the previous example is not working, you can create a macro

set "[:=goto :]%%"
set "[=rem/||(" & set "]=)"
%[:%
  multiline
  comment
%:]%

(Not works in the for loop)

Upvotes: 0

Aacini
Aacini

Reputation: 67216

You may use this trick that looks better...

@echo off
setlocal

set comment=goto endcomment

echo This line is executed

%comment%
echo These lines
echo are commented out...
:endcomment

echo The next line to execute

%comment%
You may place here
  %$#"#% anything you want.... &!>|<()
:endcomment

echo End of example

Upvotes: 2

Martin G
Martin G

Reputation: 18109

There is no such thing in batch scripts.

(gotos excluded...)

Upvotes: 1

anishsane
anishsane

Reputation: 20980

I think, this can serve the purpose

goto:skip1
echo This line should not get executed
format c: & echo nor this line
:skip1

Upvotes: 3

Related Questions