I have this batch script which flips through 5 static set variables containing a file path to an INI file which it then reads and searches for a specific string to replace.
My issue is that after if does said replacements and writes the file back to the disk, it seems to be sanitizing all instances of ! within the INI file which in turn breaks my program.
I am guessing the ! marks are being replaced due to DelayedExpansion but I need it to perform my tasks here. I am including a copy of the function with the issue, I would be very appreciative if someone could help me figure this out.
I have been stuck trying to find an answer to this for days now…
FOR %%A IN (1 2 3 4 5) DO (
SET CFG_A=!CFG_%%A!
IF "%DEBUG%"=="1" ECHO !CFG_A!
FOR /f "delims=" %%i IN ('type "!CFG_A!" ^& break ^> "!CFG_A!" ') DO (
SET "line=%%i"
SETLOCAL enabledelayedexpansion
SET "line=!line:%IP_V%=%IP%!"
>>"!CFG_A!" echo(!line!
ENDLOCAL
)
)