What I mean by that, is for example, if a file is to be moved to a directory, and the next line of code assumes the file is there and tries to open it, but the move itself is not finished, resulting in an error? Like needing to include ping localhost -n 5 between two commands?
1 Answer
If you use a regular batch, and don't implement START or alike to spawn new processes, then it will wait for the previous command to finish before continuing.
Batch won't advance to the next command until it receives an exit code from the previous command. So in the context of a basic file copy, it will wait for the copy command to complete. You can witness this by simply running a Copy command from the command prompt; it won't give you the prompt back until it's done copying.
Now, where you may run into trouble is when you launch a program that spawns new processes that do work that you need to wait for.
For example, the launcher program may exit (returning an exit code to the batch file, causing it to continue on) before the new process it started finishes doing what you need done before continuing the batch.
In those cases you'll need to either pause the batch file for an amount of time (and hope that it finishes within that time), or use a loop in the batch to monitor for the process to finish (ie: with tasklist
) before continuing.
ping 127.0.0.1 -n 6 > nul
Ofcourse 4GB will take longer than 5 seconds. DOS does not wait for 1 command to finish.If xx file exists - go to.
you get the idea.