0

What I want to do is start a .bat file that start other .cmd files. I have accomplished this with this command

start /D "path_to_folder" file1.cmd
start /D "path_to_folder" file2.cmd
start /D "path_to_folder" file3.cmd

The problem Im having is that I want the first bat that starts the other files, to close when all of the other cmd's have finished.

If I add the /WAIT command to every line, they will start one after another and not in parallel.

I've tried putting the /WAIT command on the last line, but sometimes that command finishes earlier than the others and the main bat file closes.

jovcem
  • 71
  • 1
  • 9

2 Answers2

3

This is the accepted answer at this question:

(
start /D "path_to_folder" file1.cmd
start /D "path_to_folder" file2.cmd
start /D "path_to_folder" file3.cmd
) | set /P "="

This method does not modify the standard output of the started .cmd files.

Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108
  • Interesting. Don't remember seeing you post that one before. – Squashman Jan 02 '16 at 22:52
  • Thanks for the answer, it works fine, but I use a program Backburner(network rendering) to start the bat file and when the bat file is about to exit or exit (I cant really know) I get an error in the Backburner. I know that this is the error of the program and not the bat file itself. So my question is can I use something different than: set /P "=" , cause I think that maybe is causing the problem Im having. – jovcem Jan 04 '16 at 09:33
1

We have had a few discussion about this over on dostips.com.

Here are some of the ideas they had come up with.

A.bat | B.bat | C.bat | D.bat | E.bat

Another otpion

rem you may also use the following if you wnat to see status messages of all processes.
rem A.bat>con | B.bat>con | C.bat>con | D.bat>con | E.bat

And one more

start "" /wait cmd /c temp.bat |start "" /wait cmd /c temp2.bat
Squashman
  • 13,649
  • 5
  • 27
  • 36
  • 1
    Or, you may want to use instead of `>con` to log your results: `>yourlogfile.txt` and remember the use of one `>` will overwrite your log and the use of two `>>` will apend. – Leptonator Dec 30 '15 at 15:25