从另一个批处理文件调用一个批处理,并从外部批处理设置内部批处理文件参数
Call a batch from another batch file, and set the inner batch files parameters from the outer batch
所以我不知道这是否可行,但我希望能够从外部批次调用内部批次,并能够使用外部批次在内部批次中设置参数。例如,外部批处理文件有 outerParam1
、outerParam2
、outerParam3
。然后在内部批处理文件中,它设置自己的 param1
、param2
、param3
等于外部批处理文件版本。
在批处理文件中,您可以调用另一个带参数的批处理文件,只需在文件名后添加参数,并在它们之间添加空格。例如你可以有这样的东西;
outerbatch.bat:
@echo off
set "outerParam1=hello world"
set "outerParam2=!"
call innerbatch.bat "%outerParam1%" "%outerParam2%"
innerbatch.bat:
@echo off
set "param1=%~1"
set "param2=%~2"
echo %param1% %param2%
pause
这将使 innerbatch.bat 回显:
hello world
所以我不知道这是否可行,但我希望能够从外部批次调用内部批次,并能够使用外部批次在内部批次中设置参数。例如,外部批处理文件有 outerParam1
、outerParam2
、outerParam3
。然后在内部批处理文件中,它设置自己的 param1
、param2
、param3
等于外部批处理文件版本。
在批处理文件中,您可以调用另一个带参数的批处理文件,只需在文件名后添加参数,并在它们之间添加空格。例如你可以有这样的东西;
outerbatch.bat:
@echo off
set "outerParam1=hello world"
set "outerParam2=!"
call innerbatch.bat "%outerParam1%" "%outerParam2%"
innerbatch.bat:
@echo off
set "param1=%~1"
set "param2=%~2"
echo %param1% %param2%
pause
这将使 innerbatch.bat 回显:
hello world