Windows 批处理脚本中的代码块注释语法

问题描述 投票:0回答:4

Windows批处理脚本中有多行代码块注释的语法吗?我知道

REM
::
用于逐行注释,但是注释代码块效率不高。

我正在寻找类似 PHP 中的块注释样式:

/*
This is multi-lines
block comment
*/
windows batch-file syntax comments
4个回答
2
投票

我想,这样就可以达到目的了

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

2
投票

你可以使用这个看起来更好的技巧...

@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

1
投票

批处理脚本中没有这样的东西。

(排除……)


0
投票

多行注释,没有那些讨厌的

goto
rem
::

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

编辑:由于前面的示例不起作用,您可以创建一个宏

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

(在 for 循环中不起作用)

© www.soinside.com 2019 - 2024. All rights reserved.