2013-08-29 65 views
-2

配料夫妇的批处理文件,文件一个又一个.. 这三个批处理文件完成一个任务在一个批处理等待和failmail

我的要求是

call a.bat - takes about 20 minues, so it has to wait so timeout cmd is good in batch? 
if it fails go to end 
call b.bat - takes about 5 minutes, so it has to wait 
if it fails go to end 
call c.bat - takes about 1 hour, so it has to wait 

我需要有一个适当的邮件当任何批次失败时。

我可以用同样的高效代码吗?

感谢 库马尔

回答

1

批处理文件自动等待称为批处理完成后再继续。所以你所需要担心的是错误中止。仅当先前命令失败时,条件||运算符才会执行后续命令。

我假设您的调用批处理例程正常返回错误代码失败。

@echo off 
call a.bat||goto failure 
call b.bat||goto failure 
call c.bat||goto failure 
exit /b 

:failure 
REM code to send failure email goes here 

我会把它留给谷歌寻求如何从批处理脚本发送电子邮件的答案。