Batch file if语句中的多个命令
尝试在批处理脚本的条件if中运行多个语句时出现语法错误Batch file if语句中的多个命令,batch-file,Batch File,尝试在批处理脚本的条件if中运行多个语句时出现语法错误 @echo off set COMMITTIME=%date:~-4%-%date:~-7,2%-%date:~-10,2%-%time:~-11,2%-%time:~-8,2%-%time:~-5,2% setlocal enabledelayedexpansion set COMMITTIME=!COMMITTIME:^ =0! setlocal disabledelayedexpansion if %time:~-11,2%
@echo off
set COMMITTIME=%date:~-4%-%date:~-7,2%-%date:~-10,2%-%time:~-11,2%-%time:~-8,2%-%time:~-5,2%
setlocal enabledelayedexpansion
set COMMITTIME=!COMMITTIME:^ =0!
setlocal disabledelayedexpansion
if %time:~-11,2% LEQ 5 (
echo NB /b
echo Who /b
echo ok)
echo %time:~-11,2%
if %time:~-11,2% GTR 5 (
echo Normal /b
echo menot /b
echo NOK)
::Nightly build time is less than 5 Am CET
if %time:~-11,2% LEQ 15(
echo ERROR commiting ec_baic /b
echo ERROR commiting ec_baic /b
echo ERROR commiting ec_baic)
在下面的批处理脚本中,前两个条件if有效,但第三个条件if yeids systex错误
13
Normal /b
menot /b
NOK
The syntax of the command is incorrect.
将
rem
放入该@echo off
的from中,然后让调试开始:-)
更严重的是,您会注意到工作语句和非工作语句之间的一个区别,那就是thenif
condition和左括号之间的空格
事实上,当我把它放进去时,错误就消失了:
rem +-- This is important
rem V
if %time:~-11,2% LEQ 15 (
我投票决定结束这个问题,因为这个错误是由一个简单的打字错误引起的。。。