调用其他批处理文件并处理结束

时间:2016-02-20 21:48:42

标签: windows batch-file cmd exit

我想调用两个同时执行的批处理文件。这就是它目前的样子:

BACKUP.BAT

start backup1.bat
start backup2.bat
pause

backup1.bat

Title Backup1
call do_backup.bat "param1" "param2"
exit

backup2.bat

Title Backup2
call do_backup.bat "param3" "param4"
exit

do_backup.bat

REM robocopy is called and some other things are done here
exit

如果我这样做,则会打开两个窗口,但 backup1.bat backup2.bat 未关闭(也不会退出?)。显示他们的输出,但用户无法输入新命令。只有使用Strg + C,他才能中止批处理文件,尽管它们已经完成......

我希望 backup.bat 打开 backup1.bat backup2.bat ,并且应该同时处理它们。正确的方式在新窗口中打开?在这种情况下, backup1.bat backup2.bat 窗口应在完成后关闭。看到 backup.bat 中的输出会很有趣,它应该在&#34处完成;请按任意键"如果可能的话。

那么如何处理此处的结束/退出?

1 个答案:

答案 0 :(得分:2)

再次感谢bgalea。这就是我现在所拥有的,也许稍后会修改:

BACKUP.BAT

start "" cmd /c backup1.bat
start "" cmd /c backup2.bat
pause

backup1.bat

Title Backup1
call do_backup.bat "param1" "param2"
exit /b

backup2.bat

Title Backup2
call do_backup.bat "param3" "param4"
exit /b

do_backup.bat

REM robocopy is called and some other things are done here
exit /b

似乎这就是我想要的。现在打开了两个窗口,完成后它们也会关闭。