I execute 4 tasks in parallel via command line ( win7 cmd):
start defrag /A c:
start defrag /A d:
start defrag /A e:
start defrag /A f:
dir
However the dir command execute right after the first line .
I want the dir command to execute after all 4 are done.
how can I do it ?
Try this:
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
This will cause defrag /A [drive] to run for c, d, e, and f, waiting for each to finish before starting the next. Finally, it will exit and run dir.
for %%i in (c d e f) do start "" /B /WAIT defrag /A %%i:
dir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With