Someone please help...oh, I will be so grateful. I have a very long batch file that is working perfectly except that every time the user enters input, it replaces strings in the files desired BUT it is removing the !s in the files causing issues due to them being XML config files and these are commented out sections that need to stay. I wont put the whole code in here unless requested, but in a nut shell, the user makes certain inputs and then the batch file runs...here is the part of the code for one file....the user enters the drive letter of the install and the name of the bdi server. I want the user input to replace %drive% and %bdi1%....which it does....but I do NOT want it to replace commented out sections...ie: :
<!-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message. turns into <-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message.
notice the without !
here is my code...what do i need to do to get it to stop removing the !. I tried looking on here and i thought i was well on my way with Jeb's answers but i couldnt get it to work. thanks in advance
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:server_name=%server%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:bdi_name=%bdi1%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:share_name=%share%$!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:drive_bdi=%drive%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config