I have a series of programs that work together, that are started by clicking a series of four batch (.bat) files. e.g. :
Presently I click each batch file one at a time to start these programs. What I would like to do is create a single batch file that when clicked, launches these four batch files. All of the files involved are located in the same folder.
I have tried this as a batch file:
Both of these will open alpha.bat, but then nothing else. I have tried with and without the “@echo off”, with and without “exit”, so obviously I am missing something. Many of the web sites I have checked mentioned the “call” command, but it isn’t working for me.
The version with calls should work. Get rid of the exit at the end, that’s not needed and may be causing problems. Also temporarily get rid of the @echo off at the beginning so you can see what’s happening.
You can simplify that to just start /w alpha.bat, etc.
Also, note that this will result in 5 windows opening. To avoid seeing any windows open up, you may want to use a Windows Scripting file instead of a batch file. Save the following as abcd.vbs in the same folder as the other files, and double click it to run:
You may need to check each of those called batch files to see if they themselves run additional batch files without “call”. A wrong invocation anwywhere down the line could cause the premature termination.
Thanks to all for the replies. None of the suggested resolutions worked (I didn’t try the scripting file). I now believe the problem is that there is indeed something in the first bat file that is preventing the others from opening. Until that is resolved, I don’t believe another .bat file is going to work, plus I am tired of futzing around with it. I may just try to contact the author of the program.
Is this a case of cmd.exe not being exactly compatible with the old command.com?
I was a fairly proficient .BAT programmer back in the bad old DOS days. ISTM that, as cmd.com has become increasingly entrenched and old legacy DOS stuff has been supported more and more poorly, and as old DOS programmers were forced more and more to use cmd.com because command.com either went away or didn’t play well with various Windows versions – I think I’ve seen more and more examples of incompatibilities.
Not that I can give any actual examples, because I always plugged my ears and eyes and went out of my way to pretend I could ignore all that stuff.
One way to debug things like this, if you get the inclination to futz around any more, is to comment out or delete lines and see if you can get it to work. That is, reduce your master .BAT file to simply:
(you definitely need the call command there), and reduce the alpha.bat script to just one hopefully innocuous line, and see if you can get bravo.bat to run.
If that works, try re-instating lines in alpha.bat, one line at a time, and see if you can spot the line that, when added, causes everything to break.
I spent a lot of years working with a different and totally unrelated scripting language that was driven by a very quirky and poorly documented (and buggy) interpreter, and I spent LOTS AND LOTS of time futzing around.
One more thing to try before giving up–combining my and Number’s suggestions: go for start “” /wait “cmd /c alpha.bat” That will make absolutely sure each batch file runs in a separate process.
(Microsoft themselves say that the title parameter is optional, but I guess I’ll include it just to be safe. I suspect the advice to always use it is just to deal with people who don’t use quotation marks correctly when needed.)
I guess you could also write an AutoHotkey script that would just open the folder window, select each batch file, and press Enter. Or have it open a command prompt, CD to the correct directory, and run the batch files from there.
All the speculation is kind of pointless, without seeing what is in the four separate batch files.
You shouldn’t even have to call the batch files, you would probably be better off incorporating their actual commands into a single one, but it is hard to say without seeing the actual code in the files.
Put @echo on at the top of your master .cmd file and see what runs and where it stops. If the other .bat files have @echo off then put rem in front of those statements. Redirect the output of your .cmd to a file if it scrolls too much to fit in your command window.