Page 1 of 1

neep help with call command within the batch file

Posted: 26 Feb 2010 12:58
by chinn
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

Re: neep help with call command within the batch file

Posted: 28 Feb 2010 15:38
by aGerman
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

Re: neep help with call command within the batch file

Posted: 01 Mar 2010 08:02
by chinn
Hi ..I am getting...

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

Thanks,

Re: neep help with call command within the batch file

Posted: 01 Mar 2010 08:41
by aGerman
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).

Re: neep help with call command within the batch file

Posted: 03 Mar 2010 10:55
by avery_larry
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.