0

I have four files in the same folder which I want to run one after the other in a master batch, meaning the second file should run only after the first file is finished running and so on and so forth. I have tried this:

START /wait file1.bat
START /wait file2.bat
START /wait file3.exe
START file4.bat

Saved the file as master.bat. When I run it, the first file and the second file run, but then the third file does not start. The console window stays open indicating that file2 has finished running. I tried it like this too in case the problem was that it cannot run the .exe file:

START /wait file1.bat
START /wait file2.bat
START file4.bat

Still, file4 does not run.

I also tried this:

call file1.bat
call file2.bat
call file3.exe
call file4.bat

In this case, only the first file runs and then nothing happens after. Does anyone have any idea what I could be doing wrong or how to solve this?

Mysterio
  • 139
  • 12
  • 1
    Have you considered opening up a Command Prompt window and entering both `start /?` and `call /?`, to read their usage information? `Call` is not for `.exe` files, only `.bat` or `.cmd` files. My initial suggestion would be `Call "file1.bat"`, `Call "file2.bat"`, either `"file3.exe"`, or `Start "" /Wait "file3.exe"`, and `"file4.bat"`. If there are further lines after these, change `"file4.bat"` to `Call "file4.bat"`. – Compo Feb 28 '20 at 10:03
  • 1
    You should also make sure that none of your `.bat` files have `exit` , without the `/B` option. – Compo Feb 28 '20 at 10:10
  • @Compo I tried your suggestion. Still only `file1` runs. Even without the `.exe` file, using call only calls the first batch. And none of the batches have `exit`. – Mysterio Feb 28 '20 at 10:14
  • Nevermind, I am blind. There was an `exit` in `file1`. It works now. Thanks! Edit: I am still blind. It was just a do exit in a for loop. But still it works without the first file. I don't know what the problem with file1 actually is. – Mysterio Feb 28 '20 at 10:33
  • 1
    See [debugging a batch file](https://stackoverflow.com/a/42448601/3074564). Change the first line of `file1.bat` to `@echo ON` and run the master batch file from within a command prompt window instead of double clicking on it. BTW: `exit` without `/B` always results in exiting `cmd.exe` processing the batch file(s). So it does not matter where `exit` without `/B` is used in a batch file, it exits the Windows command processor. – Mofi Feb 28 '20 at 10:50
  • @Mofi thanks for the info. Added `/B` to the `exit` in first file. Works good now! – Mysterio Feb 28 '20 at 11:48

0 Answers0