I tried to put this into a example.bat call= blahblah.exe call= example.bat /wait blahblah.exe
but the above does not wait, it will call the example.bat as soon as the blahblah.exe runs.
I want to start the example.bat when the WHOLE blahblah.exe has finished. thanks
You can use start. If you wanted to run a.bat, execute b.exe then run c.bat when it exits;
a.bat:
start /wait b.exe
call c.bat
Related
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
I need to start an exe from a batch file and after it has run it, I want the CMD prompt to exit, without waiting for the application to exit.
By just entering the location of the EXE does not work, it seems to wait for it to exit.
Is there a way to not do that with the START command?
Use CALL instead of START
call notepad.exe
echo byby
exit
In Firefox, Using Imacros, I would like to launch multiple macros from a batch file but here is the problem: I want them to run one by one. So first 'Macro 1' will run then after it completes, 'Macro 2' will run and so on till 'Macro 7'.
My BATCH CODE:
cd C:\Program Files\Mozilla Firefox
start firefox.exe
ping -n 05 127.0.0.1>nul
start firefox.exe imacros://run/?m=NAMEofMACRO.iim
Imacros VERSION BUILD=7601105
Just change your macro line to use the start switch /wait
start /wait firefox.exe imacros://run/?m=NAMEofMACRO.iim
start /wait firefox.exe imacros://run/?m=NAMEofNextMACRO.iim
start /wait firefox.exe imacros://run/?m=NAMEofNextMACRO.iim
That will launch each one, wait for it to finish, then start the next.
Another way, inside imacros, is to add at the and of each macro.iim the line
URL GOTO=imacros://run/?m=NAMEofNextMACRO.iim
So you have to run just the first macro; this macro, at the end will call the second, and the second, at the end, will call the third, and so on...
I want to call a batch2 script from a batch1 script in special case , but dont want wait parent batch1 script to wait for completion of batch2.
Want batch1 to move to next command while batch2 run in Parallel.
The NT shell command START will pass the batch file to its own Window for execution and immediately proceed to the next line.
start 1.bat
start 2.bat
You can use start like this
echo batch1 command
start batch2.bat
echo batch1 carries on whilst batch2 runs at the same time
Start command starts the 2nd batch file in the other window and both runs in parallel
#echo off
::This is the second batch file that runs in parallel with this file
start batch_file.bat
I wonder if someone can help me in DOS batch command script.
The script will run two applications i.e. app1.exe, and app2.exe. First app1.exe will run and once app1.exe has finished running then the app2.exe will run.
(Please know app1.exe must finish running before app2.exe will start)
Regards.
Use "call"
call app1.exe
call app2.exe
You can force a sequence of programs by using
#echo off
start /WAIT /B app1.exe
start /WAIT /B app2.exe
/B means that the new app will be started without creating a new window.