说实话,我不希望在这里得到一个令人满意的答案。这些命令无法调用,就是这样(据我所知,唯一不能与call一起使用的命令)。
以下是几个例子及其输出:
C:\Windows\system32>call @if a==a echo called
',' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>call (@if a==a echo called)
';' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>call if a==a echo called
'if' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>call for %a in (1) do @echo called
'for' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>call @for %a in (1) do @echo called
'+' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>call (@for %a in (1) do @echo called)
';' is not recognized as an internal or external command,
operable program or batch file.
我有一些疑虑,IF和FOR是否真正是“实际”命令——它们只是决定将命令提示符控制传递到它们后面的行(或括号块),这会导致调用混乱。不过,即使在调用FOR或IF时存在语法错误,也会被检测出来:
C:\Windows\system32>call (@if a= echo called)
= was unexpected at this time.
C:\Windows\system32>call (for %a (1) do echo called)
(1 was unexpected at this time.
所以至少解析工作已完成。