1

Is there any syntax for multi-line code block comment in Windows batch script? I knowREM 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-linesblock comment*/
Martin G's user avatar
Martin G
18.4k12 gold badges91 silver badges105 bronze badges
askedDec 11, 2014 at 8:14
Sithu's user avatar
2

4 Answers4

3

I think, this can serve the purpose

goto:skip1echo This line should not get executedformat c: & echo nor this line:skip1
answeredDec 11, 2014 at 8:43
anishsane's user avatar
Sign up to request clarification or add additional context in comments.

Comments

2

You may use this trick that looks better...

@echo offsetlocalset comment=goto endcommentecho This line is executed%comment%echo These linesecho are commented out...:endcommentecho The next line to execute%comment%You may place here  %$#"#% anything you want.... &!>|<():endcommentecho End of example
answeredDec 11, 2014 at 18:11
Aacini's user avatar

Comments

1

There is no such thing in batch scripts.

(gotos excluded...)

answeredDec 11, 2014 at 9:31
Martin G's user avatar

Comments

0

Multiline comment without those nastygotos,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)

answeredFeb 10, 2021 at 10:00
Sheol-Nugganoth's user avatar

2 Comments

How is this supposed to work? What does @break normally do? (Also, this syntax didn't work for me in a batch file. It still executed the excluded lines)
@gamingexpert13 Sets or clears extended CTRL+C checking on MS-DOS systems. If used without parameters, break displays the existing setting value. If command extensions are enabled and running on the Windows platform, inserting the break command into a batch file enters a hard-coded breakpoint if being debugged by a debugger. Details:learn.microsoft.com/en-us/windows-server/administration/…

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.