DOS batch file to run 4 blocks of 3 parallel programs - batch-file

The program is a FORTAN number-crunching code :: "C:\fct1d_intel_2\debug\fct1d_intel_2.exe"
This is called using the batch file "RUN.bat":
C:\fct1d_intel_2\debug\fct1d_intel_2.exe
exit
The following batch file "run_generator_3procs_1to3.bat" kicks-off the 3 parallel programs in separate directories:
CD C:\FCT_Polystyrene_Model_Calibration\Proc_01
start /min run.bat
CD C:\FCT_Polystyrene_Model_Calibration\Proc_02
start /min run.bat
CD C:\FCT_Polystyrene_Model_Calibration\Proc_03
start /min run.bat
The following batch file "run_12_cases_4X3.bat" calls 4 sequential versions of of the preceding batchfile:
call run_generator_3procs_7to9.bat
call run_generator_3procs_10to12.bat
call run_generator_3procs_1to3.bat
call run_generator_3procs_4to6.bat
Now the first call "run_generator_3procs_7to9.bat" runs the 3 parallel programs fine but does not move on to the next 3 batch files.
Could anyone please advise me on what I am doing wrong.

Check that you are not trying to access files at the same time with different batch files. It might be executing, but just closing as they fail to run.

Related

How to don't quit batch file from another script with exit /b 0

I have a program1.cmd file that finishes the commands with exit /b 0. This program cannot be edited.
I've created a test.bat and I must call program1.cmd, however, I need to process in sequence program2.cmd and then program3.exe. How to do that?
When you want to call one batch file from another (whether .BAT or .CMD), you should use the CALL command to return to the calling batch file. See SS64 on CALL for more information. Using the information you gave in your question, TEST.BAT would contain the following commands:
CALL program1.cmd
CALL program2.cmd
program3
REM could also be CALL program3.exe, but doesn't need to be.
(If the two .CMD files and the .EXE are not in the same directory as TEST.BAT, you would need to supply paths to them, not just the file names.)

Use batch file to insert command in a prompt opened by another batch file

I am using the QGIS software, which includes the OSGeo4W.bat file. This file opens a prompt, rewrite the path variables and include some others, like the python2 enviroment and some sitepackages like the Qt4 installed with QGIS. When opened the .bat file, it opens:
The problem is that i need to insert many commands in here so many times per day, like this one that converts a .ui file made by QtDesigner in .py:
pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
As this is too much time consuming, i decided to write a batch file, call the OSgeo4W.bat and just add theses commands, but it doesnt work. The commands after the call are not runned. How can i run commands in a batch file inside the prompt created by another batch file? I am using Windows8.1. my batch file
#echo off
call "C:\Program Files\QGIS 2.18\OSGeo4W.bat"
pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
rem more codes here
pause
You could try the Start command to execute the commands, you could also use timeout to wait before each of the executions.
#echo off
call "C:\Program Files\QGIS 2.18\OSGeo4W.bat"
start pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
start rem more codes here
//you can use timeout 5 to wait to execute next command
start rem ***
start rem ***
pause

Executing bat files one by one

What I got is a list of bat files:
file1.bat
file2.bat
…
file29.bat
I need them to run one after each other. Meaning when the file1.bat closes file2.bat starts and so on.
I tried this, but it doesn't work properly:
start /wait call file1.bat
start /wait call file2.bat
You might want to add more to your question to make it easier to understand. My guess is that you want the bat file to open the next one then close itself after that.
If that's what you want to do; add these commands to each of the files:
start file2.bat
exit
Of course, you'll want to change start file2.bat to start file3.bat and so on for each file.
If you want file1.bat to manage all of the files, I don't think that's possible in batch.
You didn't describe how exactly it's not doing what you expected. I'm guessing that what happens is you're having to shut down each script before the next one will continue.
Documentation on start says:
WAIT Start application and wait for it to terminate.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If you must use start then you could force it to use the /c switch which will automatically close the window once it's done:
start /wait cmd /c call file1.bat
I'm not really sure you accomplish anything by using call so that ought to be equivalent to just:
start /wait cmd /c file1.bat
Using start creates a new window for each program and you may just want to have it all run in a single command processor window.
As noted by Biffin you can just list them all out in a master script and they will run in order.
call file1.bat
call file2.bat
...
call file29.bat
And a shorthand for that is:
for /l %%f in (1; 1; 29) do call file%%f.bat
Remember to double up those percent characters inside a batch script but not on the command line.
This question might explain some of the unexpected behavior you were seeing.
How to run multiple .BAT files within a .BAT file

Run multiple batch files from one master batch

I have multiple batch files. Each batch file opens an exe file and run a command. The command compiles the results in csv format. This all works like heaven.
I am trying to create a master batch which could run each of the batch file one by one.
The individual batch file names are as 1.bat, 2.bat . . . .32.bat
I tried,
Call 1.bat
Call 2.bat
.
.
.
Call 32.bat
but it is only running the first command...
I also tried without call, same result.
I am using the following code in each batch file:
Start /D "C:\test 2\" CSC.exe "1.lq"
Start /D "C:\test 2\" CSC.exe "2.lq"
and so on
Can anyone help me crack this?
All I want My master bat to run first batch, on completion run second and so on so forth.
Hope it makes sense.
I really appreciate your help on this guys.
Shei
Try like this:-
START /WAIT batch1.bat
START /WAIT batch2.bat

what does start/wait means in batch file

In batch file, what does start/wait means
Example:
ECHO start/wait C:\\Example.exe
I am trying to run an exe, so what does start/wait indicates over here?
/wait forces the batch file to halt processing until the called program has finished executing.
(This can be useful, for example, if you are loading multiple items in your windows Startup folder, and the nature of the programs require that one be finished before the next starts loading. Put them all in a single batch file, using the /wait parameter, and only put a shortcut to the batch file in the Startup folder.) Command line parameters of the START command can be combined in a single line. Example:
START /max /wait NOTEPAD.EXE SOME.TXT
Source: http://aumha.org/a/batches.php

Resources