Batch file 如何创建从另一个文件读取参数的批处理文件
omeone帮助我创建一个批处理文件,从同一目录下的另一个文件(例如Config.conf)中读取3个参数 配置文件包含以下信息: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
--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