这是批处理代码块中的一种模糊效果。
在代码块中,一行中的标签始终需要具有完全不同语法规则的辅助行(对于辅助行)。
SO:goto 命令不起作用
第二行必须是命令或简单标签,但不能是括号、双冒号或附加括号的内部命令。
MC ND 解释说:这里使用的就像一个普通的驱动器号,这是真的!
但只有在辅助行中,甚至您可以通过 a 来抑制错误subst :: C:\,该行就像标签一样处理(您无法启动任何内容)。
subst :: C:\
(
:label
::\windows\system32\calc.exe
)
&即使该行是标签,辅助行也接受。
不合格样品
(
:Label at the end fails
)
(
:label
(
echo new Block fails
)
echo ...
)
(
:label
:: Double colon fails
)
(
:label
echo( fails also, as now a file named "echo(" is searched for execution
)
现在工作的
(
::Works
:with a "normal" label in the second line
)
(
:But this label! & echo This will not echo'd
:but & echo You can see this !
)
(
:label
echo or a simple command works too
)
有时::用作注释样式,如果您不关心辅助行,这可能会导致块内部出现问题。
编辑:回答你的第二个问题
确定 :: 是指“注释开头”还是“驱动器号冒号”的规则是什么?
第一个::始终是注释或标签,在下一行中始终是drive letter colon.