Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Operating System - Microsoft
cancel
Showing results for 
Search instead for 
Did you mean: 

How to call another batch from one batch file

SOLVED
Go to solution
Mannoj
Occasional Advisor

How to call another batch from one batch file

I have a batch file which runs normal basic commands at the last line it should call another batch file

Help me with this....plss
8 REPLIES
OFC_EDM
Respected Contributor

Re: How to call another batch from one batch file

C:\>type 1.bat
@echo off
call 2.bat

C:\>type 2.bat
@echo off
echo hello


Run 1.bat and the result will be:
C:\>1.bat
hello

1.bat called 2.bat

Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: How to call another batch from one batch file

No question is silly as we all have those kind of days :)
The Devil is in the detail.
Mannoj
Occasional Advisor

Re: How to call another batch from one batch file

Kevin u are correct.. I'm still stucked up..

D:\f1.bat

In
f1.bat - u have
echo Hi dude u r in f1 file
@pause
f2
@pause
f3
@pause
echo all the files are executed
@pause

in D:\f2.bat

In f2.bat - u have
echo Hi dude u r in f2 file

Inf f3.bat - u have
echo Hi dude u r in f3 file


In the above case i wanna call using the same f1.bat file to exec both f1 and f2 but how wil i do this...?
Peter Nikitka
Honored Contributor

Re: How to call another batch from one batch file

Hi,

though your question is faaaar from HP-UX:

In a .bat file the variable
%0%

contains the filename used at execution time.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
OFC_EDM
Respected Contributor
Solution

Re: How to call another batch from one batch file

In
f1.bat - u have
echo Hi dude u r in f1 file
@pause
call f2.bat
@pause
call f3.bat
@pause
echo all the files are executed
@pause

-------------
Note the call statements i put in front of f1 and f2. And added their extensions as part of normal coding technique
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: How to call another batch from one batch file

Here it is in action....I hope i'm not doing someones homework assignment??


C:\>type f1.bat
@echo off
echo Hi dude u r in f1 file
@pause
call f2.bat
@pause
call f3.bat
@pause
echo all the files are executed
@pause

C:\>type f2.bat
@echo off
echo Hi dude u r in f2 file

C:\>type f3.bat
@echo off
echo Hi dude u r in f3 file

Now to execute f1.bat and see the result:
==========================================
C:\>f1.bat
Hi dude u r in f1 file
Press any key to continue . . .
Hi dude u r in f2 file
Press any key to continue . . .
Hi dude u r in f3 file
Press any key to continue . . .
all the files are executed
Press any key to continue . . .

NOTE:
Put the @echo off at the beginning of each .bat file.

Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: How to call another batch from one batch file

Hi Mannoj,

I'm getting in the habit of not answering questions for those who don't post points. As there are people out there who've asked hundreds of questions and don't assign points.

You're not one of them. I see you're brand new to the forums and haven't assigned any points yet.

It's good etiquette to say thank you with points. Patrick Wallek put up some suggested etiquette guidlines for all of us.

Here's the link
http://66.34.90.71/ITRCForumsEtiquette/

Also...Welcome to the ITRC forum. Hope you enjoy it.

Regards


Also here's a linke to the HP support forums - overview and FAQs

http://forums11.itrc.hp.com/service/forums/helptips.do?

Which contains:

How many points should I assign to replies?

Every response to your question is eligible to earn between 1-10 points. No need to worry about running out of points - when a truly awesome reply rolls in that deserves a 10, you will be able to assign it a 10! However, be careful to assign points based on the value that a reply truly provides. Use the following scale as a guideline:

o N/A: The answer was simply a point of clarification to my original question

o 1-3: The answer didn't really help answer my question, but thanks for your assistance!

o 4- 7: The answer helped with a portion of my question, but I still need some additional help!

o 8-10: The answer has solved my problem completely! Now I'm a happy camper!
The Devil is in the detail.
Mannoj
Occasional Advisor

Re: How to call another batch from one batch file

Hey Thanks to all..