String BATCH CMD-读取带有特殊字符的INI文件
我正在读取一个config.ini文件,我想使用KEY作为变量名,VALUE作为VALUE Config.iniString BATCH CMD-读取带有特殊字符的INI文件,string,variables,batch-file,cmd,dos,String,Variables,Batch File,Cmd,Dos,我正在读取一个config.ini文件,我想使用KEY作为变量名,VALUE作为VALUE Config.ini fbdestination=I:\WZPDA\workingfolder\stored emailreport=xxx@xxxx.xxx gmailudpw=USERNAME:PASSWORD 即时通讯使用: FOR /F "tokens=1,2 delims=^=" %%A IN (config.ini) DO (SET %%A=%%B) 一切正常,但我有一个复杂的密码问题,如
fbdestination=I:\WZPDA\workingfolder\stored
emailreport=xxx@xxxx.xxx
gmailudpw=USERNAME:PASSWORD
即时通讯使用:
FOR /F "tokens=1,2 delims=^=" %%A IN (config.ini) DO (SET %%A=%%B)
一切正常,但我有一个复杂的密码问题,如:
myusername:!myp4ssw0rd!
如果我尝试回显$gmailudpw$,我只有:
myusername:
有没有阅读的方法!myp4ssw0rd!作为字符串而不是变量
谢谢你试着这样做:
@echo off
setlocal disabledelayedexpansion
FOR /F "tokens=*" %%A IN ('type "config.ini"') DO SET %%A
echo %fbdestination%
echo %emailreport%
echo %gmailudpw%
您无法从命令
类型中获得任何可见结果。仅通过命令echo
。如果您不需要它,请将其移除。我已经删除了echo命令,因为我只需要变量,但我必须将cls放在“set%%A”之后,以隐藏整个ini内容。