1.

Solve : Wait - pause command issue?

Answer»

Hi
I use batch files to carry out all sorts or functions, however i am no coding expert.

I wish to copy serveral files from VARIOUS places which are networked (I have mapped the drives already), the problem I have is that the batch runs to the end before the first process is finished - i need it to wait before carrying out the next function.

copy w:\test1.mdb c:\test\test1.mdb
copy w:\test2.mdb c:\test\test2.mdb

I can not specify a time as it may alter due to good/bad network connection, and would rather there be no user input.
Thank you

How are you suppost to cause a delay without using some sort of time?
How long does this delay need to be ?

How is the batch running to the end before the first process is finished? i dont get it, Post up your entire script.. its likely malformed batch script.Make each COMMAND in it's own batch file and call them one by one, using Code: [Select] start /wait which will wait for the batch file to finish before calling the next command.

FBWell like I said I am no expert, i got some of this to work by doing the following.

first.bat file
copy c:\test1\test1.txt c:\test2\test1.txt

second.bat file
copy c:\test1\test2.txt c:\test2\test2.txt

execute.bat file
start c:\first.bat wait/
start c:\second.bat

I run the execute file and it works - however it leaves 2 dos windows up at the same time, and I am sure there is a simpler way

Thanks for the response all the same.Quote from: pythag on October 19, 2008, 05:34:27 AM

Well like I said I am no expert, i got some of this to work by doing the following.

execute.bat file
start c:\first.bat wait/
start c:\second.bat

Did you really use the part in bold? Like that?

You should do this

start /wait c:\first.bat

Quote
however it leaves 2 dos windows up at the same time

Put this as a last (second) line of each batch file

Code: [Select]exitQuote
copy w:\test1.mdb c:\test\test1.mdb
copy w:\test2.mdb c:\test\test2.mdb

Quote
the problem I have is that the batch runs to the end before the first process is finished

I don't understand how this is possible. The command shell is not multi-threaded and can only process one command at a time.

If you insist on using the start command with the /wait SWITCH, try adding the /b switch to keep all the processing in the same window. Multiple windows only adds to the confusion.





I did wonder if the command processor might return after starting a COPY operation from a networked drive to another, that is to say, the copy is DONE asynchronously? If not, I share your confusion. I note that the OP has not stated the local OS nor the server or other machines OSs.


Many thanks for the response's - its working by keeping it simple

First.bat
Code: [Select]copy w:\test1\test1.txt c:\test2\test1.txt
exitSecond.bat
Code: [Select]copy w:\test1\test2.txt c:\test2\test2.txt
exitExecute.bat
Code: [Select]start c:\test1\first.bat
start c:\test1\second.bat
W is the mapped drive

In answer to some of the other points - I am using Vista mapped to an XP machine across a local wireless network (all set up throught standard windows controls, with a standard network).
The /wait command was just confusing matters - i placed it wrong a few times and had all kind of errors.
The /b switch - didnt even go down this road ALTHOUGH made a note of that one for the future.

Question now is can I do this without having to create differrent bat files for every file/folder I want to copy?

But again thanks I can now get my back ups done


Discussion

No Comment Found