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.
Related
I would like to know how to start a batch file minimized without creating a shortcut.
I also want the code on how to relaunch a batch file minimized without using a VBS
So if anyone knows how to start the batch file minimized from the first launch that would be great.
try with this and this:
#echo off
echo self minimizing
call getCmdPid.bat
call windowMode.bat -pid %errorlevel% -mode minimized
echo --other commands--
pause
By adding some powershell
#echo off
echo This batch will minimize and return to normal in 5 second intervals.
timeout /t 5 >nul
powershell -window minimized -command ""
timeout /t 5 >nul
powershell -window normal -command ""
echo and We're back..
if you want to use nothing other than batch, then the wrong way, as we do not really start batch files, would be:
start "" /min "batchfilename.cmd"
If you run this from another batch file, that batch file will remain open, unless you exit it. So in order to run it in your actual batch file, it would be something like:
echo Hello!
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~0" %* && exit
timeout /t 10
exit
The timeout here just gives you some time to see the window running minimized.
I'm currently working on a batch file that should download files via their URL and them run formatting script on them however I don't know how to to delay the batch-file during downloading, however since it's a direct download the window doesn't stay open.
here's where I'm at :
START "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui
MOVE C:\\Users\\*\\downloads\\*.csv %~dp0
EXIT
I would like to wait for the first line to finish before continuing.
Thanks for your consideration
From cmdline (cmd.exe) run start /? and you will find some help. There is a specific line in the help file for the /wait switch which reads:
WAIT Start application and wait for it to terminate.
So simply start chrome with the /wait switch:
Start /wait "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui
As per your comment, the above will not work. It is probably best to test if the file exists, chrome will have a .crdownload extension when still downloading. So let's test that the *.csv.crdownload does not exist.
start /wait "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui
:hold
timeout 5
if /i not exist *.csv.crdownload (MOVE "C:\\Users\\*\\downloads\\*.csv" %~dp0) else ( goto :hold)
exit
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
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...
As the title says what parameters would you use in a batch file to continually execute a command e.g.
start notepad
loop
Another option in a single line (which will also work from the command line):
for /l %x in (1,0,2) do (start /wait notepad)
If you're using that in a batch file, use
for /l %%x in (1,0,2) do (start /wait notepad)
instead.
Use goto:
:loop
start /wait notepad
goto loop
Note that I have used start /wait here. If you don't do that, your batch file won't wait for notepad to exit, and you'll start a zillion notepads and probably eventually crash.