简体   繁体   English

如何使用输入参数从另一个.bat调用.bat。 文本

[英]How to call .bat from another .bat with input parameters . txt

How to call .bat from another .bat with input parameters txt 如何使用输入参数txt从另一个.bat调用.bat
I got args.txt file from source.bat that contains parameter values of source.bat. 我从source.bat获得了args.txt文件,其中包含source.bat的参数值。

    args.txt  conatins "E:\DEstination" "E:\SSSS1" "PWD" "UID" "DB_SERVER" "DBNAME"

Now I want to call destin.bat using args.txt params . 现在我想使用args.txt params来调用destin.bat。

I tried to call from test.bat like below, 我试图从test.bat像下面这样打电话,

    call destin.bat args.txt .

but this way didn't work 但是这种方式不起作用

    set pPath=%~1
    set iPath=%~2
    set DBUserID=%~3
    set DBPassword=%~4
    set DBurl=%~5
    set DBNAME=%~6

Please suggest me some other way to call .bat from .bat with .txt inputs . 请建议我使用.txt输入从.bat调用.bat的其他方法。 Thanks in advance 提前致谢

for /f "delims=" %%a in (args.txt) do call destin.bat %%a

阅读该行并将其用作调用的参数

You can read the arguments into a variable eg: 您可以将参数读入变量,例如:

set /p args= < args.txt
call destin.bat %args%

The /p with set looks for standard input to populate the variable (this would usually be provided by the user). set的/ p查找用于填充变量的标准输入(通常由用户提供)。 Using the < symbol before the file name redirects data from the file to the standard input (which is then used to set the variable). 在文件名前使用<符号可以将数据从文件重定向到标准输入(然后用于设置变量)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM