'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
*/
Solution 1:[1]
I think, this can serve the purpose
goto:skip1
echo This line should not get executed
format c: & echo nor this line
:skip1
Solution 2:[2]
There is no such thing in batch scripts.
(gotos excluded...)
Solution 3:[3]
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
Solution 4:[4]
Multiline comment without that 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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | anishsane |
| Solution 2 | Martin G |
| Solution 3 | Aacini |
| Solution 4 |
