0

我正在运行以下 windows .bat 脚本,但遇到了麻烦。

@echo off
set /p Var1= Drag and drop your .itmsp folder here: 

CALL C:\progra~2\itms\iTMSTransporter -m verify -f %Var1% -u username -p password -o %Var1%\log.txt -s shortname -v eXtreme WONoPause true

IF %ERRORLEVEL% == 0 goto PASS
else goto FAIL

:PASS
blat c:\temp\file.txt -to user@example.com -subject "This has passed"
exit

:FAIL
blat c:\temp\file.txt -to user@example.com -subject "This has failed"
exit

该命令运行但 ERRORLEVEL 似乎不起作用,只报告 0,没有别的。请问有什么建议吗?

4

1 回答 1

0

我会说你不需要 start 命令。IF-ELSE 语法是错误的,但您实际上不需要 else 部分。我敢打赌你需要引用参数。尝试这个:

@echo off
set /p Var1= Drag and drop your .itmsp folder here: 

CALL C:\progra~2\itms\iTMSTransporter -m verify -f "%Var1%" -u username -p password -o "%Var1%\log.txt" -s shortname -v eXtreme WONoPause true

rem fail if ERRORLEVEL >= 1 otherwise continue
IF ERRORLEVEL 1 goto FAIL

blat c:\temp\file.txt -to user@example.com -subject "This has passed"
goto:EOF

:FAIL
blat c:\temp\file.txt -to user@example.com -subject "This has failed"
于 2014-02-06T21:51:59.147 回答