I have a simple ini file... really just a key=value file that I want to use to set as variables for my script.
My ini file:
DATABASE=snoopy
My Batch file code
@echo off
SET DATABASE=woodstock
FOR /f "tokens=1,2 delims==" %%a in ('C:\mycfg.ini') do (
echo a=%%a
echo b=%%b
pause
SET %%a=%%b
ECHO DATABASE=%DATABASE%
)
The echo a and b are correct, it shows
a=DATABASE
b=snoopy
But at the end when I echo %DATABASE% after calling the SET %%a=%%b It still shows
DATABASE=woodstock
If I use delayed expansion, it works but only locally. I need it to overwrite the global so I don't see why this shouldn't work.
localversusglobal? Islocalthe current CMD window andglobalthe set of environment variables that are set when you open a new CMD window from the Start Menu (e.g., all future CMD windows)? BTW - You won't be able to modify other already open CMD windows. - James L.ECHO DATABASE=!DATABASE!- indiv