PC Review


Reply
Thread Tools Rate Thread

calling multiple batch files from within a batch file

 
 
yawnmoth
Guest
Posts: n/a
 
      26th May 2008
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?
 
Reply With Quote
 
 
 
 
smlunatick
Guest
Posts: n/a
 
      26th May 2008
On May 26, 1:25*pm, yawnmoth <terra1...@yahoo.com> wrote:
> 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?


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"



 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      26th May 2008

"yawnmoth" <(E-Mail Removed)> wrote in message
news:95e1dd1e-49d5-4e4e-8c76-(E-Mail Removed)...
>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?


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

@echo off
call hello
call hello


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      26th May 2008

"smlunatick" <(E-Mail Removed)> wrote in message
news:f1407952-74c9-4557-92c0-(E-Mail Removed)...
On May 26, 1:25 pm, yawnmoth <terra1...@yahoo.com> wrote:
> 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?


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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a batch file in context menu with _multiple_ parameters files Vinzz Windows XP Help 1 20th Sep 2005 10:49 PM
calling a batch file Jim Simpson Microsoft Excel Programming 2 14th May 2004 06:57 PM
Calling Batch within a Batch file Bobby Stiklus Microsoft Windows 2000 Developer 1 27th Apr 2004 06:40 PM
Calling Batch within a Batch File ChuckR Microsoft Windows 2000 Developer 0 22nd Apr 2004 02:33 AM
Photo Editor Batch supporting batch compression JPG files 29150 Freeware 2 23rd Jun 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 PM.