评论代码行
要对代码进行注释,可以使用 &::或 &rem。你也可以使用 && 或||来取代 &。
示例:
@echo off
echo This is a test &::This is a comment
echo This is another test &rem This is another comment
pause
好奇心 :SET 命令允许在没有 &rem 的情况下进行有限的内联评论:
set "varname=varvalue" limited inline comment here
限制:
- 双引号
set "varname=varvalue"或set "varname="的语法, - 内联注释可能不包含任何双引号,
- 任何
cmd有毒字符| < > &必须正确地转义^| ^< ^> ^&, - 括号
( )必须在括号内的代码块中正确转义为^( ^)。