0

I have a batch file, updatesipversion.bat that is calling another batch file, template.bat.

updatesipversion.bat code:

set init=empty
set main=svn propget svn:externals ./3c > install\msbuild\SipBranchDefaultDetailsTemplate.txt 
set error=update
set action=empty

call template.bat "%init%" "%main%" "%error%" "%action%"

set init=empty
set main=install\msbuild\SipBranchDetails.exe
set error=update
set action=empty

call template.bat "%init%" "%main%" "%error%" "%action%"

template.bat code

set /a WAcounter=0
for %%a in (%*) do set /a WAcounter+=1
if not %WAcounter%==4 goto :Error
set WAinit=%1
set WAmain=%2
set WAerror=%3
set WAaction=%4
set /a WAcounter=0

:WAinitCommand
IF NOT %1=="empty" %WAinit:~1,-1%

:WAmainCommand
set /a WAcounter+=1
IF NOT %2=="empty" %WAmain:~1,-1%
if %errorlevel%==0 goto :WASuccess

:WAerrorMsg
IF NOT %3=="empty" echo ERROR in %WAerror:~1,-1% Trying again......
if %WAcounter% equ 10 goto :Finish 
goto :WAmainCommand

:WASuccess
IF NOT %4=="empty" %WAaction:~1,-1%
exit

:Finish
exit 

:Error
echo there must be 4 command line arguments
exit
pause

When the for command in first call to template.bat call if %errorlevel==0% then it exits from :WASuccess, if not it exits from :Finish.

The second time template is not called or other command are not executed.

Please tell me if first command is exited, how to continue with making second template call.

Thanks

2
  • for readability can you please edit your post and make the code parts lokk liek code? Commented Jun 2, 2010 at 11:33
  • Note that you can use %~1, etc. to automatically strip the quotes which would make the rest of that batch much easier to read. Commented Jun 11, 2010 at 1:14

1 Answer 1

1

You should use either start instead of call, or use exit /B or goto :eof from your called batch. See this for reference.

Sign up to request clarification or add additional context in comments.

1 Comment

Good point on exit /b or goto :eof. The part about start is nonsense, though, unless they want to run template.bat asynchronously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.