Batch file 使用特定的goto命令开始批处理
我想知道是否有可能从另一批启动一个特定goto函数中的批精简Batch file 使用特定的goto命令开始批处理,batch-file,goto,process.start,Batch File,Goto,Process.start,我想知道是否有可能从另一批启动一个特定goto函数中的批精简 因此,不仅要启动另一个批处理文件,还要让“母”批处理在“子”批处理中选择一个特定的转到选项。只要让父/母批处理文件并将参数传递给子批处理文件即可 妈妈。蝙蝠 @ECHO OFF ECHO Here we go CALL child.bat 3 PAUSE @ECHO OFF IF "%1"=="1" Goto 1 IF "%1"=="2" Goto 2 IF "%1"=="3" Goto 3 EXIT :1 ECHO 1
因此,不仅要启动另一个批处理文件,还要让“母”批处理在“子”批处理中选择一个特定的转到选项。只要让父/母批处理文件并将参数传递给子批处理文件即可 妈妈。蝙蝠
@ECHO OFF
ECHO Here we go
CALL child.bat 3
PAUSE
@ECHO OFF
IF "%1"=="1" Goto 1
IF "%1"=="2" Goto 2
IF "%1"=="3" Goto 3
EXIT
:1
ECHO 1!
PAUSE
EXIT
:2
ECHO 2!
PAUSE
EXIT
:3
ECHO 3!
PAUSE
EXIT
call second.bat :theFunction
call :theFunction
echo back in main
exit /b
:theFunction
second.bat
echo back in the func in main, this line will never reached
exit /b This line will also never reached
child.bat
@ECHO OFF
ECHO Here we go
CALL child.bat 3
PAUSE
@ECHO OFF
IF "%1"=="1" Goto 1
IF "%1"=="2" Goto 2
IF "%1"=="3" Goto 3
EXIT
:1
ECHO 1!
PAUSE
EXIT
:2
ECHO 2!
PAUSE
EXIT
:3
ECHO 3!
PAUSE
EXIT
call second.bat :theFunction
call :theFunction
echo back in main
exit /b
:theFunction
second.bat
echo back in the func in main, this line will never reached
exit /b This line will also never reached
这个例子应该是回声3当母批处理文件将参数3传递给子批处理文件时。是的,但这是一个错误 通常情况下,您需要从调用的批处理文件中获得一些帮助 main.bat
@ECHO OFF
ECHO Here we go
CALL child.bat 3
PAUSE
@ECHO OFF
IF "%1"=="1" Goto 1
IF "%1"=="2" Goto 2
IF "%1"=="3" Goto 3
EXIT
:1
ECHO 1!
PAUSE
EXIT
:2
ECHO 2!
PAUSE
EXIT
:3
ECHO 3!
PAUSE
EXIT
call second.bat :theFunction
call :theFunction
echo back in main
exit /b
:theFunction
second.bat
echo back in the func in main, this line will never reached
exit /b This line will also never reached
*第二,蝙蝠
黑客使用了一个功能错误,你只需要与second.bat相同的标签。
只有在不调用的情况下启动第二个.bat时,它才起作用
main.bat
@ECHO OFF
ECHO Here we go
CALL child.bat 3
PAUSE
@ECHO OFF
IF "%1"=="1" Goto 1
IF "%1"=="2" Goto 2
IF "%1"=="3" Goto 3
EXIT
:1
ECHO 1!
PAUSE
EXIT
:2
ECHO 2!
PAUSE
EXIT
:3
ECHO 3!
PAUSE
EXIT
call second.bat :theFunction
call :theFunction
echo back in main
exit /b
:theFunction
second.bat
echo back in the func in main, this line will never reached
exit /b This line will also never reached
当第二个.bat返回时,它将返回到正在调用的批处理文件main.bat中的调用后的行,将其置于顶部
if not %1=="" goto :%1
在批处理文件中,您使用它来调用put
call b.bat labelname
显然,这是有限的,这取决于您试图做什么,但基本功能工作。1.bat
call 2.bat /c goto :this
call 2.bat /c call :that
if "%1"=="/c" shift & shift & %2 %3
goto :eof
:this
echo This!
goto :eof
:that
echo That!
goto :eof
2.bat
call 2.bat /c goto :this
call 2.bat /c call :that
if "%1"=="/c" shift & shift & %2 %3
goto :eof
:this
echo This!
goto :eof
:that
echo That!
goto :eof
编辑:我原来的帖子最接近正确。但是我已经改正了我的错误
我双击shift键将%1和%2移到左边,将传递给%1和%2位置的任何其他变量移到左边。然后我执行%2和%3,因为在执行/解释该行之前,移位的效果不会生效。+1,为什么要检查%1
?只要跳到它也应该work@jeb-我想这取决于您如何命名Goto参数,以及您是否可以修改子批处理文件,但这一点很好。我无法让任何一个建议正常工作。调用函数是否理想,因为我试图让Mom bat使用%0调用其自身,并在新窗口中打开goto函数。这样,我可以保持不同的函数打开,并继续在original@LittleBobbyTables对不起,你的球棒不是我想要的。我有一个带有difrent函数的bat,我想将其中的一些函数扩展到一个新窗口中,这样我就可以在屏幕上同时看到多个函数,否则我将使用一个窗口在函数之间跳转。这有意义吗?是否应该启动C:\CHILD.bat函数\u X\u内部\u CHILD\u bat\u非\u MOTHER\u bat
?为什么在参数中传递GOTO
?为什么移动两次却没有任何效果?@jeb-Oops,我错了。一定比我想象的更累了。好主意,但还是不行:-)因为换班对同一时间的%1%2
没有影响line@jeb-唉,我会做好的。我想当我告诉别人他们需要在发布代码之前测试代码时,我需要引起注意。8\