neep help with call command within the batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
chinn
Posts: 2
Joined: 26 Feb 2010 12:49

neep help with call command within the batch file

#1 Post by chinn » 26 Feb 2010 12:58

I have two batch files..bat1 and bat2

bat1
has some code


if certain error level Call bat2 :starthere

...i want to call bat2 and not run the whole thing but start at certain point


My bat2 is something like this..

:StartHere
Echo bat2

and exit here and dont need to return to bat1.


can you please let me know if i can do this...
Thanks in advance

aGerman
Expert
Posts: 3786
Joined: 22 Jan 2010 18:01
Location: Germany

Re: neep help with call command within the batch file

#2 Post by aGerman » 28 Feb 2010 15:38

Your bat2.bat could contain something like that:

Code: Select all

@echo off
if not "%~1"=="" goto %~1
...
:starthere
...



The call in bat1.bat could be:

Code: Select all

@echo off
...
call bat2.bat starthere
...


Regards
aGerman

chinn
Posts: 2
Joined: 26 Feb 2010 12:49

Re: neep help with call command within the batch file

#3 Post by chinn » 01 Mar 2010 08:02

Hi ..I am getting...

bat2.bat is not a recognized as an internal or external programme....

Thanks,

aGerman
Expert
Posts: 3786
Joined: 22 Jan 2010 18:01
Location: Germany

Re: neep help with call command within the batch file

#4 Post by aGerman » 01 Mar 2010 08:41

Have you saved the first code as bat2.bat in the same folder as bat1.bat? What's your OS? Try without the CALL command (only bat2.bat starthere).

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: neep help with call command within the batch file

#5 Post by avery_larry » 03 Mar 2010 10:55

I wouldn't use the call command since it's not supposed to return to bat1. Otherwise you have to execute an exit command in bat2.

Post Reply