我通过命令行(win7 cmd)在 并行 中执行 4 个任务:

start defrag /A c:
start defrag /A d:
start defrag /A e:
start  defrag /A f:
dir

然而 dir 命令在第一行之后立即执行。

我希望 dir 命令在所有 4 个完成后执行。

我该怎么做 ?

最佳答案

试试这个:

start defrag /A c:
start defrag /A d:
start defrag /A e:
start defrag /A f:

:StartLoop
:: Check whether any of the defrags are running...
tasklist|Findstr /i /c:"defrag"
:: Exiting the loop if tasklist didn't find any defrags.
If %errorlevel% NEQ 0 (
   GoTo :ExitLoop
)
choice /T 10 /D Y /M "Waiting for 10 seconds..."
GoTo :StartLoop
:ExitLoop
dir

关于windows - CMD - 等待并行命令行完成?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13087885/

10-11 01:13