为什么我不能叫" IF"和"对于"无论是在批,也不在cmd? [英] Why I can't CALL "IF" and "FOR" neither in batch nor in the cmd?
问题描述
说实话,我不指望一个令人满意的答案here.These命令不能被调用,这是它(据我知道,不能调用中使用的唯一命令)。
以下是他们的输出几个例子:
C:\\ Windows \\ System32下>调用@if一个==一个名为回声
','不被识别为内部或外部的命令,
可运行的程序或批处理文件。C:\\ Windows \\ System32下>调用(@if一个==一个名为回声)
';'不被识别为内部或外部的命令,
可运行的程序或批处理文件。C:\\ Windows \\ System32下>调用如果一个==称为回声
如果不被识别为内部或外部的命令,
可运行的程序或批处理文件。C:\\ Windows \\ System32下>呼吁%一(1)不要叫@echo
关于'不被识别为内部或外部的命令,
可运行的程序或批处理文件。C:\\ Windows \\ System32下>调用@for(1)不要叫@echo%A
+不被识别为内部或外部的命令,
可运行的程序或批处理文件。C:\\ Windows \\ System32下>调用(@for(1)不要叫@echo%A)
';'不被识别为内部或外部的命令,
可运行的程序或批处理文件。
我有一些怀疑,认为如果并没有实际上是真实的命令 - 他们只是决定通过命令提示符控制线(或支架块),在他们身后与否,这混淆了电话。
无论如何,即使如此,当有语法错误呼吁或者如果他们发现:
C:\\ Windows \\ System32下>调用(@if一个=回应称呼)
=在这个时候意外。C:\\ Windows \\ System32下>调用(用于%A(1)并称为回声)
(1在这个时候意外。
所以至少解析就完成了。
您说的很对。
的
,如果
和 REM
不的正常的内部命令(但REM也存在一个正常的内部版本)。结果
他们使用自己的特殊分析器(每一个不同的)。
看来,这些指令被转换为一种令牌。结果
因此,你有这样意外的错误消息(还有更多可能的字符),错误/令牌性格也取决于Windows版本(如果我记得正确的在这里)。结果
也许呼叫
命令从原来的命令只看到符号化的数据。
命令块不与呼叫命令在所有的工作,也&放大器; |<>
不正常工作。
调用(一^ |一)
有关命令搜索/标记 2
,所以如果你创建了一个名为批处理文件 2.bat
即可与调用启动它(^ |一)。
有关更多信息呼叫
结果
Dostips:打电话给我,或更好的避免调用结果
Dostips:限制CMD处理内部命令,更安全,更快速
To be honest I don't expect a satisfying answer here.These command cannot be called and that's it (as far as I know the only commands that cannot be used with call). Here are few examples with their output:
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.
I have some suspicious , that IF and FOR are not in fact 'real' commands - they just decide to pass the command prompt control to the line (or brackets block) behind them or not , which confuses the call. Anyway even that , when there are syntax errors in called FOR or IF they are detected:
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.
So at least the parsing is done.
You are quite right.
FOR
, IF
and REM
aren't normal internal commands (but for REM exists also a normal internal version).
They use an own special parser (each a different one).
It seems that these commands are translated to a sort of token.
Therefor you got such unexpected error messages (there are much more possible characters), the error/token character depends also of the Windows version (if I remember correct here).
Probably the CALL
command sees only the tokenized data from the original command.
Command blocks don't work at all with the call command, also &|<>
don't work as expected.
call (a^|a)
Searches for a command/token 2
, so if you create a batch file named 2.bat
you can start it with call (a^|a)
.
For further information about CALL
Dostips:CALL me, or better avoid call
Dostips:Limit CMD processing to internal commands, safer and faster?
这篇关于为什么我不能叫&QUOT; IF&QUOT;和&QUOT;对于&QUOT;无论是在批,也不在cmd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!