如何编写一个批处理文件来获取输入变量并将其发送到另一个批处理文件进行处理。
第 1 批
我不知道如何将变量发送到批处理 2,这是我的问题。
第 2 批
if %variable%==1 goto Example
goto :EOF
:Example
echo YaY
最佳答案
您根本不需要做任何事情。批处理文件中设置的变量在其调用的批处理文件中可见。
示例
测试1.bat
@echo off
set x=7
call test2.bat
set x=3
call test2.bat
pause
test2.bat
echo In test2.bat with x = %x%.
输出
...当 test1.bat 运行时。
In test2.bat with x = 7.
In test2.bat with x = 3.
Press any key to continue . . .
关于batch-file - 如何将变量从一个批处理文件传递到另一个批处理文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27595440/