Frage

I'm reading a config.ini file and i want to use KEY as a Variable name with VALUE as VALUE.

Config.ini

fbdestination=I:\WZPDA\workingfolder\stored
emailreport=xxx@xxxx.xxx
gmailudpw=USERNAME:PASSWORD

Im using:

FOR /F "tokens=1,2 delims=^=" %%A IN (config.ini) DO (SET %%A=%%B)

Everything works well, but I have a problem with a complex password like:

myusername:!myp4ssw0rd!

Where if I try to ECHO $gmailudpw$ I only have :

myusername:

Is there a way to read !myp4ssw0rd! as a string and not as a variable ?

Thank you

War es hilfreich?

Lösung

Try like this :

@echo off
setlocal disabledelayedexpansion
FOR /F "tokens=*" %%A IN ('type "config.ini"') DO SET %%A
echo %fbdestination%
echo %emailreport%
echo %gmailudpw%
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top