Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsWindows VistaWindows XPWindows MeWindows 98Windows 95Virtual PCInternet ExplorerOutlook ExpressWindows MediaSecurity
Related Topics
MS Server ProductsMS OfficePC HardwareMore Topics ...

Windows Forum / Windows XP / General Topics 1 / May 2008

Tip: Looking for answers? Try searching our database.

calling multiple batch files from within a batch file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
yawnmoth - 26 May 2008 18:25 GMT
I have two batch files - hello.cmd and hello2.cmd.

Here's the contents of hello.cmd:

@echo hello, world!

Here's the contents of hello2.cmd:

@hello
@hello

Why is "hello, world!" only output once?
smlunatick - 26 May 2008 18:33 GMT
> I have two batch files - hello.cmd and hello2.cmd.
>
[quoted text clipped - 8 lines]
>
> Why is "hello, world!" only output once?

You need to note that any "*.cmd files are Windows Script files and
not batch files (older DOS files.)

The first line "sends" the control over the hello, but there is no
means of return.

Add "call" to before hello

@call "hello"
Pegasus (MVP) - 26 May 2008 18:47 GMT
On May 26, 1:25 pm, yawnmoth <terra1...@yahoo.com> wrote:
> I have two batch files - hello.cmd and hello2.cmd.
>
[quoted text clipped - 8 lines]
>
> Why is "hello, world!" only output once?

You need to note that any "*.cmd files are Windows Script files and
not batch files (older DOS files.)
<snip>
=================

Mhm. What exactly is the difference betwee a "Windows Script File"
and a "Batch File"? I used to think that a "Batch File" is an ASCII
file that contains a number of commands such as copy, md, del. Batch
files have a .bat or a .cmd extension. I'm not so sure about a "Windows
Script File" - the closest that comes to my mind is a "VB Script File",
which is something else again.

Under WinNT,2000,XP and Vista, files with a .cmd extension are
treated in exactly the same way as those with a .bat extension. No
difference there.
Pegasus (MVP) - 26 May 2008 18:35 GMT
>I have two batch files - hello.cmd and hello2.cmd.
>
[quoted text clipped - 8 lines]
>
> Why is "hello, world!" only output once?

. . . because the first @hello invokes hello.cmd, without
control ever returning to hello2.cmd. Try this instead:

@echo off
call hello
call hello
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.