【问题标题】:Run multiple robocopy command in a batch file在批处理文件中运行多个 robocopy 命令
【发布时间】:2015-11-15 11:43:48
【问题描述】:

我正在尝试在批处理文件中运行多个 robocopy 命令。但是在运行第一个命令批处理文件后退出。从不运行下一个命令。
我该如何解决?或者我如何一次运行多个 robocopy 命令?
例如。 diff.bat 代码是
robocopy %1 %2 /E /L /FP /log:%3.log

然后我想用不同的源目录和目标目录调用 diff.bat 3 次

.\diff.bat \\sorucedir1\ \\distdir1\ mylog1
.\diff.bat \\sorucedir2\ \\distdir2\ mylog2
.\diff.bat \\sorucedir3\ \\distdir3\ mylog3

【问题讨论】:

  • 你能提供一些代码吗?否则,我们如何帮助您解决?
  • 为什么你认为 for 循环会起作用?这也是多次调用相同的命令。不是吗?

标签: batch-file cmd robocopy


【解决方案1】:

当从批处理文件中调用批处理文件时,流程执行被转移到被调用的文件,并且不会返回给调用者。

如果想要流程执行返回给调用者,需要使用call命令。

call .\diff.bat \\sorucedir1\ \\distdir1\ mylog1
call .\diff.bat \\sorucedir2\ \\distdir2\ mylog2
call .\diff.bat \\sorucedir3\ \\distdir3\ mylog3

【讨论】:

    猜你喜欢
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多