Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何创建从另一个文件读取参数的批处理文件_Batch File_Parameters_Parameter Passing_Configuration Files - Fatal编程技术网

Batch file 如何创建从另一个文件读取参数的批处理文件

Batch file 如何创建从另一个文件读取参数的批处理文件,batch-file,parameters,parameter-passing,configuration-files,Batch File,Parameters,Parameter Passing,Configuration Files,omeone帮助我创建一个批处理文件,从同一目录下的另一个文件(例如Config.conf)中读取3个参数 配置文件包含以下信息: --url="jdbc:oracle:thin:@192.168.0.91:1521:xe" --username=TestUser01 --password=passowrd01 我需要在我的MIG.bat文件中设置3个参数%url%,%username%,%pwd%,它们正在使用这些参数 感谢并问候如果一切都在同一条线上并且顺序相同 @echo off set

omeone帮助我创建一个批处理文件,从同一目录下的另一个文件(例如Config.conf)中读取3个参数

配置文件包含以下信息:

--url="jdbc:oracle:thin:@192.168.0.91:1521:xe" --username=TestUser01 --password=passowrd01
我需要在我的MIG.bat文件中设置3个参数%url%,%username%,%pwd%,它们正在使用这些参数


感谢并问候

如果一切都在同一条线上并且顺序相同

@echo off
setlocal
    set "cfgFile=c:\test.cfg"

    for /f "tokens=2,4,6 delims==- " %%a in ('type "%cfgFile%"^| find /i "url"') do (
        set "URL=%%~a"
        set "user=%%~b"
        set "pass=%%~c"
    )

    echo %URL% %user% %pass%
endlocal

我现在还有第二个解决方案

我已更改Config.conf:

--url = jdbc:oracle:thin:@192.168.0.91:1521:xe"
--username=TestUser01
--password=passowrd01 
我的test.bat:

@echo off
setlocal
    for /f "usebackq tokens=1 delims=--" %%A in ("%cd%\config.conf") do (
        set "%%A"
    )
    echo %url%
    echo %username%
    echo %password%
endlocal

配置文件的外观如何?--url=“jdbc:oracle:thin:@192.168.0.91:1521:xe”--username=TestUser01--password=passowrd01