I'm making a batch file to run 3 setup.
But i can't execute them all in the same time, so i'm asking if there is a solution to launch the second setup after the end of the first.
I tried /wait ,/b , call but nothing work.
I have this for the moment :
#echo off
start "" ".\01_Drivers\Drivers 2018\NI-DAQmx 18.0 (RunTime 4)\setup.exe"
start "" /wait ".\01_Drivers\Drivers 2018\NI-VISA 18.0 RTE\setup.exe"
start "" /wait ".\01_Drivers\Drivers 2018\NI-LabVIEW 18.0 RTE\setup.exe"
exit
Thanks for help
Related
I have a batch file which launches let's say 10 applications one after the other.
It waits till the launched application finishes and then proceeds to next one. There is no problem here.
However I am unable to capture (in the batch file) the console output which each of the 10 called applications produce.
Below is what I am talking about:
start /wait ./TestApp1/Debug/TestApp1.exe
start /wait ./TestApp2/Debug/TestApp2.exe
start /wait ./TestApp3/Debug/TestApp3.exe
start /wait ./TestApp4/Debug/TestApp4.exe
start /wait ./TestApp5/Debug/TestApp5.exe
start /wait ./TestApp6/Debug/TestApp6.exe
start /wait ./TestApp7/Debug/TestApp7.exe
start /wait ./TestApp8/Debug/TestApp8.exe
start /wait ./TestApp9/Debug/TestApp9.exe
start /wait ./TestApp10/Debug/TestApp10.exe
Lets say each of the TestApp generate some output.
I want to consolidate all of them into one text file.
Any pointers on how to achieve this?
I would suggest you first of all try it without the Start command:
#(
"TestApp1\Debug\TestApp1.exe"
"TestApp2\Debug\TestApp2.exe"
"TestApp3\Debug\TestApp3.exe"
"TestApp4\Debug\TestApp4.exe"
"TestApp5\Debug\TestApp5.exe"
"TestApp6\Debug\TestApp6.exe"
"TestApp7\Debug\TestApp7.exe"
"TestApp8\Debug\TestApp8.exe"
"TestApp9\Debug\TestApp9.exe"
"TestApp10\Debug\TestApp10.exe"
) > "logfile.txt"
If you really do need that Start command, then similarly:
#(
Start "" /Wait "TestApp1\Debug\TestApp1.exe"
Start "" /Wait "TestApp2\Debug\TestApp2.exe"
Start "" /Wait "TestApp3\Debug\TestApp3.exe"
Start "" /Wait "TestApp4\Debug\TestApp4.exe"
Start "" /Wait "TestApp5\Debug\TestApp5.exe"
Start "" /Wait "TestApp6\Debug\TestApp6.exe"
Start "" /Wait "TestApp7\Debug\TestApp7.exe"
Start "" /Wait "TestApp8\Debug\TestApp8.exe"
Start "" /Wait "TestApp9\Debug\TestApp9.exe"
Start "" /Wait "TestApp10\Debug\TestApp10.exe"
) > "logfile.txt"
If your application requires the use of Start, then you would be well advised to take a look at its usage information, (options such as /B may also be needed).
Please note, that I've included doublequotes, such that the script can be used as a template for others, without worrying about problematic characters, and I've also used the correct path separators for Windows, i.e. the back slash.
I'm trying my hand at some light programming, but have hit a wall I'm hoping someone can help me with. I'm using an HTPC and a front end media center called Kodi. Within Kodi I have a program called advanced launcher. As my MC Kodi is scripted to always be on top, I've been using a batch file for each PC game and program I'm trying to run. It shuts down Kodi, launches the program, and when the program is closed, relaunches Kodi. This works fine for most programs, but if it has a launcher attached (the example I have is for Dragon Age: Inquisition and the launcher it has Origin) it will run straight through the entire batch file without waiting as I thought I had instructed it. This only seems to happen in programs that have launchers. As I'm just starting out, while lines to change or add would be great to get this working, I'd also like to know the reason behind the changes.
pskill Kodi.exe
cd /d "I:\Games\Dragon Age Inquisition\"
start /max /wait Dragon Age Inquisition.exe
ping 192.168.1.46 -n 1 -w 15000 > nul
cd /d "C:\Program Files (x86)\Kodi\"
start /max Kodi.exe
Ps Commands were recommended by a friend, not sure if this is also an issue, just seems odd that any program without a launcher works fine, but with a launcher just doesn't seem to function correctly. Thanks for your valuable time.
try with:
start "" /max /wait Dragon Age Inquisition.exe
and
start "" /max Kodi.exe
First argument is always the title.
Taskkill /im Kodi.exe
"I:\Games\Dragon Age Inquisition\Dragon Age Inquisition.exe"
"C:\Program Files (x86)\Kodi\Kodi.exe"
Should work how you expect.
Taskkill is the correct command. Use it with /f to force closing.
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 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.
I have the following problem:
I have created a batch script which calls itself in there (for being able to write a log in parallel). In the script I start another process (like start startServer.bat) which starts up a java process and keeps opened up all the time.
In my original script I wait 30 seconds, check if the process is running and do an:
exit /B 0
Unfortunately that does not work, the window shows that the exit /B 0 is being evaluated, but the window still keeps open. When I close the window with the other process (meaning the "child" processes started up in my .bat) my script continues its run.
So:
scriptA.bat
-> in there I call: start startServer.bat
-> wait 30 seconds
-> check is server is started
-> exit /B 0
Process hangs up!
What's very odd, if I wrap another script around, like:
scriptB.bat
-> call scriptA.bat
-----> in there I call: start startServer.bat
-----> wait 30 seconds
-----> check if server is started
-----> exit /B 0
-> scriptA.bat continues without any hangup!
I also tried the same with exit 0 (without /B) also, same result! In the first case it hangs up, in the second case my window closes as expected...
Has anyone of you ever had such a problem before and knows what's wrong here?
Process hangs up!
There's a good explanation of all the options for exiting a batch script here:
http://www.robvanderwoude.com/exit.php
Specifically, from that page:
The DOS online help (HELP EXIT) doesn't make it clear that the /B parameter exits the current instance of script which is not necessarily the same as exiting the current script.
I.e. if the script is in a CALLed piece of code, the EXIT /B exits the CALL, not the script.
So you definitely don't want exit /b 0 in this case. If just exit 0 doesn't work, try GOTO:EOF.
The earlier answer from Vicky is very good. There is some additional undocumented (or, at least, unclear) behaviour going on here.
In your question, you have a somewhat more complicated situation, but let's say you are calling/starting a batch file from the original, using exit /b 0 in the called batch file, and expecting that the ERRORLEVEL is accessible in the original.
Original
#echo off
start "" /b /wait cmd /c "startServer.bat"
if ERRORLEVEL 1 echo Exit code is one & exit /b 1
if ERRORLEVEL 0 echo Exit code is zero & exit /b 0
Child batch file
#echo off
exit /b 0
To get this to work, the start command must be used with the certain options. Depending on the options, they may need to be in a specific order. (!)
According to the docs at SS64 on Start, you should be able to use the /b and /wait switches. The documentation does not state that the order of these switches matters, but it does.
For instance, this will NOT work (commands run out of order, and ERRORLEVEL is not returned):
start "" /wait /b cmd /c "startServer.bat"
But this does work exactly as expected:
start "" /b /wait cmd /c "startServer.bat"
The only difference is swapping the /b and /wait switches.
I discovered this by accident, using the following steps:
Checked all the documentation I could find on start and call and cmd
Banged my head on the wall for a few hours trying everything I could think of
Gave up, and came back 24 hours later
I did not try anything new, I just started over, and it worked the first time. Comparing to previous file versions showed me this (apparently) small difference. Turns out, there is no such thing as a "small" change!
I guess your problem lies within the start command. The following excerpt from the start /? help might point to the issue:
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 it is not an internal cmd command
or batch file then it is a program and
will run as either a windowed
application or a console application.
As a solution you could try to modify the start command like this:
start "" cmd /c "startServer.bat"