Batch file how to call another batch file at a specified label or call and immediately goto a certain label?

Viewed 9124

I am trying to figure out how file1.bat can call file2.bat at a specified label.

I figured I can do it like this:

File1.bat

:config
@echo off
:setvars
set labelmarker=labelmarker
call file2.bat
pause > nul
:EOF

File2.bat

if %labelmarker%==labelmarker goto label4
:label1
echo it won't work...
goto EOF
:label2
echo it must work!
goto EOF
:label3
echo it didn't work...
goto EOF
:label4
echo it works!
goto EOF
:EOF

This works. but I want to call a bat AND the Label from file1.bat. is it possible with a control character or ascii code or anything? like i tried

call file2.bat | goto label4 - doesn't work
call file2.bat > goto label4 - doesn't work
call file2.bat @label4 - doesn't work

Any help would be greatly appreciated.

Even if it involves extracting a specific label and contents to a new file would be ok.

5 Answers
Related