# Help with a Windows 7 batch file

**URL:** <https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809>\
**Category:** Factual Questions\
**Created:** [August 2, 2015, 4:36pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809 "2015-08-02T16:36:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oglomott](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/oglomott/32/3543_2.png) [@Oglomott](https://boards.straightdope.com/u/Oglomott)\
**Post date:** [August 2, 2015, 4:36pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/1 "2015-08-02T16:36:49Z")

</div>

I have a series of programs that work together, that are started by clicking a series of four batch (.bat) files. e.g. :

alpha.bat  
bravo.bat  
charlie.bat  
delta.bat

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:

@echo off  
alpha.bat  
bravo.bat  
charlie.bat  
delta.bat  
exit

And this:

@echo off  
call alpha.bat  
call bravo.bat  
call charlie.bat  
call delta.bat  
exit

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. ☹

---

<div class="post-metadata">

**Author:** ![RealityChuck](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/realitychuck/32/195_2.png) [@RealityChuck](https://boards.straightdope.com/u/RealityChuck)\
**Post date:** [August 2, 2015, 5:13pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/2 "2015-08-02T17:13:09Z")

</div>

If alpha.bat has an exit command in it, it probably ends the entire batch file. Remove that command from each of the .bat files and run the first example to see if that helps

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [August 2, 2015, 5:16pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/3 "2015-08-02T17:16:30Z")

</div>

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.

–Mark

---

<div class="post-metadata">

**Author:** ![Oglomott](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/oglomott/32/3543_2.png) [@Oglomott](https://boards.straightdope.com/u/Oglomott)\
**Post date:** [August 2, 2015, 7:24pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/4 "2015-08-02T19:24:30Z")

</div>

> [@markn\_1](#):
>
> 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.
> 
> –Mark

The version with the calls opens only the first .bat file, with the exit removed or not. AFAICT, there’s no exit command in any of the four .bat files.

---

<div class="post-metadata">

**Author:** ![Quartz](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/quartz/32/267_2.png) [@Quartz](https://boards.straightdope.com/u/Quartz)\
**Post date:** [August 2, 2015, 7:33pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/5 "2015-08-02T19:33:23Z")

</div>

Try renaming them all to .cmd By having them all as .bat you’re invoking [command.com](http://command.com) each time so information may be getting lost. And it’s the call version you want.

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [August 2, 2015, 10:12pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/6 "2015-08-02T22:12:37Z")

</div>

.bat vs. .cmd hasn’t mattered since NT 4. They now run identically.

As **RealityChuck** said, there’s probably something in alpha.bat that’s preventing the others from running. If you’re willing to, posting the contents of it would help.

You could also try

```auto

@echo off
start "" /wait alpha.bat
start "" /wait bravo.bat
start "" /wait charlie.bat
delta.bat

```

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [August 2, 2015, 10:33pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/7 "2015-08-02T22:33:52Z")

</div>

I can confirm what **RealityChuck** said. The EXIT command at the end of a batch file causes the command interpreter itself to exit. And it is not necessary in order to end a batch file.

Don’t just guess, open the files and check.

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [August 2, 2015, 11:19pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/8 "2015-08-02T23:19:46Z")

</div>

> [@Number](#):
>
> You could also try
> 
> ```auto
> 
> @echo off
> start "" /wait alpha.bat
> start "" /wait bravo.bat
> start "" /wait charlie.bat
> delta.bat
> 
> ```

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:

```php
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run("cmd /c alpha.bat",0,true) 
WshShell.Run("cmd /c bravo.bat",0,true) 
WshShell.Run("cmd /c charlie.bat", 0, true) 
WshShell.Run("cmd /c delta.bat", 0, true)

```

The “0” is what hides the window, and the “true” makes each command wait before executing the next one. I’m not sure if the cmd /c is necessary, but I’m not where I can test it right now.

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [August 2, 2015, 11:22pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/9 "2015-08-02T23:22:56Z")

</div>

> [@BigT](#):
>
> You can simplify that to just start /w alpha.bat, etc.

Not including a value for window title can lead to unpredictable behavior from start.

---

<div class="post-metadata">

**Author:** ![andrewm](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@andrewm](https://boards.straightdope.com/u/andrewm)\
**Post date:** [August 2, 2015, 11:38pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/10 "2015-08-02T23:38:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Oglomott](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/oglomott/32/3543_2.png) [@Oglomott](https://boards.straightdope.com/u/Oglomott)\
**Post date:** [August 3, 2015, 12:02am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/11 "2015-08-03T00:02:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [August 3, 2015, 12:07am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/12 "2015-08-03T00:07:50Z")

</div>

Is this a case of cmd.exe not being exactly compatible with the old [command.com](http://command.com)?

I was a fairly proficient .BAT programmer back in the bad old DOS days. ISTM that, as [cmd.com](http://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](http://cmd.com) because [command.com](http://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.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [August 3, 2015, 12:13am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/13 "2015-08-03T00:13:19Z")

</div>

> [@Oglomott](#):
>
> 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.

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:

```auto

call alpha.bat
call bravo.bat

```

(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.

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [August 3, 2015, 12:37am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/14 "2015-08-03T00:37:06Z")

</div>

> [@Oglomott](#):
>
> 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.

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](https://technet.microsoft.com/en-us/library/Cc770297.aspx) 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.)

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [August 3, 2015, 12:42am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/15 "2015-08-03T00:42:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andrewm](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@andrewm](https://boards.straightdope.com/u/andrewm)\
**Post date:** [August 3, 2015, 12:45am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/16 "2015-08-03T00:45:18Z")

</div>

The start command title argument is optional if and only if the command argument contains no spaces.

---

<div class="post-metadata">

**Author:** ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)\
**Post date:** [August 3, 2015, 1:31am UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/17 "2015-08-03T01:31:47Z")

</div>

Why don’t you just post their code?

---

<div class="post-metadata">

**Author:** ![Khendrask](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Khendrask](https://boards.straightdope.com/u/Khendrask)\
**Post date:** [August 3, 2015, 2:59pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/18 "2015-08-03T14:59:18Z")

</div>

> [@Reply](#):
>
> Why don’t you just post their code?

This.  
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.

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [August 3, 2015, 9:27pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/19 "2015-08-03T21:27:46Z")

</div>

> [@Reply](#):
>
> Why don’t you just post their code?

I assumed he was worried about having permission to share the code. Or maybe he thinks it might be insulting to the person not to give them first crack at fixing it.

---

<div class="post-metadata">

**Author:** ![Corner\_Case](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/corner_case/32/234_2.png) [@Corner\_Case](https://boards.straightdope.com/u/Corner_Case)\
**Post date:** [August 3, 2015, 10:03pm UTC](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809/20 "2015-08-03T22:03:30Z")

</div>

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.

[Next page](https://boards.straightdope.com/t/help-with-a-windows-7-batch-file/726809.md?page=2)
