Why I can't CALL “IF” and “FOR” neither in batch nor in the cmd?

前端 未结 3 1757
不知归路
不知归路 2020-12-01 15:35

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

3条回答
  •  臣服心动
    2020-12-01 16:08

    After all it is possible to call IF and FOR ..or almost;

        @echo off
    
    rem :: this will produce an error
    rem if a equ a
    
    rem :: And this too
    rem call if a equ a rem
    
    rem :: But this will not!!!
    call if a equ a
    
    rem :: This will not too ((\but in command prompt single % is enough)
    call for %%%%a in (.) do
    
    rem :: And this
    call if a equ a for %%%%a in (.) do if 1 equ 1  for %%%%a in (.) do if c==c
    
    rem :: And this
    call if a equ a for %%%%a in (.) do if 1 equ 1 for %%%%a in (.) do if c==c ( rem rem rem echo something
    

    Despite I see no usage of this.

提交回复
热议问题