Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file &引用;)这在当时是出人意料的。”;批量运行嵌套IF_Batch File_If Statement - Fatal编程技术网

Batch file &引用;)这在当时是出人意料的。”;批量运行嵌套IF

Batch file &引用;)这在当时是出人意料的。”;批量运行嵌套IF,batch-file,if-statement,Batch File,If Statement,不知道为什么会这样。试着向上看。。。我想看起来不错 IF not (%5) == () ( call %antPath% -f %buildFile% runSoapUI -DserviceName=%1 -DoperationName=%2 -DinputData=%3 -DlogID=%4 -DtestType=%5 ) ELSE ( IF not (%4) == () ( call %antPath% -f %buildFile% runSoapUI -Ds

不知道为什么会这样。试着向上看。。。我想看起来不错

IF not (%5) == () (
    call %antPath% -f %buildFile% runSoapUI -DserviceName=%1 -DoperationName=%2 -DinputData=%3 -DlogID=%4 -DtestType=%5
) ELSE (
    IF not (%4) == () (
        call %antPath% -f %buildFile% runSoapUI -DserviceName=%1 -DoperationName=%2 -DinputData=%3 -DlogID=%4 -DtestType=FILE
    ) ELSE (
        call %antPath% -f %buildFile% help
    )
)

正如Mat所说,在if语句中使用括号是个坏主意。 更好的方法是使用引号,因为引号可以防止%n内容中的许多特殊字符出现问题,如空格、
&(

如果任何变量中都有a
,则调用语句也可能出现问题

你可以通过延迟扩展来解决这个问题

setlocal EnableDelayedExpansion
IF not "%5" == "" (
    call !antPath! -f !buildFile! runSoapUI -DserviceName=%1 -DoperationName=%2 -DinputData=%3 -DlogID=%4 -DtestType=%5
) ELSE (
    IF not "%4" == "" (
        call !antPath! -f !buildFile! runSoapUI -DserviceName=%1 -DoperationName=%2 -DinputData=%3 -DlogID=%4 -DtestType=FILE
    ) ELSE (
        call !antPath! -f !buildFile! help
    )
)

您是否尝试过将
if not(a)==()
更改为
if not[a]=[]
(两者)?