如何将变量从一个批处理文件传递到另一个批处理文件? [英] How to pass variables from one batch file to another batch file?
本文介绍了如何将变量从一个批处理文件传递到另一个批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何编写一个批处理文件,该批处理文件获取输入变量并将其发送到另一个要处理的批处理文件.
How do I write a batch file which gets an input variable and sends it to another batch file to be processed.
第1批
我不知道如何将变量发送到批次2,这是我的问题.
I don't know how to send a variable to batch 2 which is my problem here.
第2批
if %variable%==1 goto Example
goto :EOF
:Example
echo YaY
推荐答案
您根本不需要做任何事情.在批处理文件中设置的变量在其调用的批处理文件中可见.
You don't need to do anything at all. Variables set in a batch file are visible in a batch file that it calls.
示例
@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运行时.
Output
... when test1.bat runs.
In test2.bat with x = 7.
In test2.bat with x = 3.
Press any key to continue . . .
这篇关于如何将变量从一个批处理文件传递到另一个批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文