Help with a Windows 7 batch file

Close. I finally got access to a Win7 machine, and the problem is not the spaces but using quotation marks. If the first non-switch or switch-related parameter is surrounded by quotation marks, it’s assumed to be a title.

It’s just that you also have to use quotation marks if the filename you wish to invoke contains spaces. But spaces (and quotations) are fine for passing a parameter to the file you are invoking.

What a strange way to design that command. Heck, since titles are so rarely used, I don’t know why it’s not a switch.

I remember doing something similar back-in-the-day by faking it with Windows Task Scheduler in the windows system tools. I created event-based tasks (instead of time based) to invoke a series of .bat files that pushed updated files from a file server to a web server. Ugly, but it worked :slight_smile:

On a slight tangent, depending on what you’re trying to accomplish, it might just be easier to rewrite the whole thing in (all free) Powershell, VBscript, Visual Studio Express, or python/php/whatever. Batch files are a real bitch to work in.

Why not end alpha.bat with
call beta.bat
and so on?

I do that. The reason I don’t just incorporate beta.bat into alpha.bat is that alpha.bat writes the file beta.bat as part of its processing.

Boy, I started a mess, didn’t I? :eek:

I was ready to give up. But wait!

As a test, I created this batch file:

@echo off
call calc.exe
call notepad.exe
call regedit.exe

When I double click on this .bat file, do you know what happens? Windows Calculator opens. That’s it. But, when I close Calculator, then Notepad opens. Then, when I close Notepad, Regedit opens. The same issue as with the other .bat files.

So, why don’t all three programs open one after another, without closing the previous one? It is a missing .bat file command?

If you want them to run at the same time, try the start instead of call command.

Ignore this, double post

That’s the way batch files work (in MS DOS>Windows anyway). They finish one line, then do the next line. calc.exe isn’t finished until the user closes it, and the batch file won’t run notepad.exe until calc.exe is finished. Likewise, your alpha, bravo, Charlie file won’t run bravo.bat until alpha finishes.

If you want to start alpha.bat and then run bravo.bat before alpha has finished, I don’t think you can do that with a .bat file.

The start command works!

Here is an explanation I just received:

“My guess is that you’re just attempting to execute the batch files in series. that is not working because the first batch file is running in the foreground and the 2nd batch file won’t execute until the first one is done. You need to use START:”

Code:

>start /?
Starts a separate window to run a specified program or command.

START [“title”] [/D path] * [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] **
[command/program] [parameters]

Cool, so did that solve your problem? Wasn’t entirely clear from your post whether that did it.

(You just replace the “call” with “start”) like:



@echo off
start alpha.bat
start beta.bat
start charlie.bat


Yes, exactly. Problem is solved. Thanks to all who replied.

Does the start command, used the way you say, run all three batch files more-or-less simultaneously, or does it run them strictly sequentially? And, for your purposes, does it matter?

The start command has a /w parameter, that instructs it to wait for the started program to complete before the next line of the batch file can run. I thought that the default, without the /w parameter, is to start the specified program, but then immediately move on to the next line of the batch file without waiting for the started program to exit.

What is the behavior you are seeing?

So, this whole time, the problem has been that you actually wanted them to run at the same time? And, apparently, batch File A gets stuck and never actually ends?

The program requires that all four batch files be open and running at the same time. Without the “start” command, only the first one would run, no matter what order I placed them in. the second one would would not run unless I exited the first one, etc.

Look at my example in post #25. You can duplicate the same behavior using Windows calculator, notepad, etc. Without the “start” command, only the first program will open; the next one opens only after you close the first one.

My knowledge of batch files is only enough to create very simple ones; beyond that I require help. :wink:

I’m glad you got your problem solved.

What baffled me, and judging from most of the early replies, most other posters, was that we thought you wanted a batch file that ran Alpha, Bravo, Charlie, and Delta in sequence, not in parallel. And your problem was that when Alpha ended the master .bat file also ended, so Bravo never started at all.

The key to getting (and giving) good advice on any topic, but most especially on computer topics, is to be very *very *explicit and complete about what you’re saying. Most folks are unaware of all the many assumptions they’ve built into their understanding of their problem. Which assumptions they then leave out of their question.

Even correct advice is confusing when it answers a question you didn’t ask and solves a problem you don’t have.

By the very mention of “Bat files”, which are an archaism from the DOS days, led us all to believe that you were trying to do a DOS type of thing. Parallel execution of multiple programs was more-or-less unheard of in DOS systems, and was pretty much literally unthinkable to do with a batch file. So we were all looking for ways to make your whole conglomeration of batch files work just like they would have in DOS, I think.

This video link shows the program I am using, and may explain the usage of the bat files.

DSDPlus