批处理文件如何调用另一个批处理文件在指定的标签或呼叫,并立即后藤一定的标签? [英] Batch file how to call another batch file at a specified label or call and immediately goto a certain label?
问题描述
我试图找出如何file1.bat可以在指定的标签调用file2.bat。
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
这工作。但我想打电话给一只蝙蝠,并从file1.bat标签。
是否有可能与控制字符或ASCII code或什么?
像我试图
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
任何帮助将大大AP preciated。
Any help would be greatly appreciated.
即使它涉及提取特定的标签和内容,以一个新的文件将是确定的。
Even if it involves extracting a specific label and contents to a new file would be ok.
推荐答案
您可以通过标签你想要去作为一个参数
You could pass the label you want to go to as a parameter
的示例脚本
的 First.bat 的
@echo off
set label=GOHERE
call Second.bat %label%
pause >nul
的 Second.bat 的
@echo off
goto %1
echo This line should be skipped
:GOHERE
echo Jumped here
这篇关于批处理文件如何调用另一个批处理文件在指定的标签或呼叫,并立即后藤一定的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!