0

I have a line in my config file (.exe.config)

 <appSettings configSource="Configuration\local.config" />

And I need use a batch file to change it to

 <appSettings configSource="Configuration\production.config" />

Any ideas?

Kay
  • 70
  • 2
  • 8

1 Answers1

0

This is going to be very brittle and prone to error, but if you still want to do it, go ahead:

  1. We need delayed expansion

    setlocal enabledelayedexpansion
    
  2. Iterate over the lines in the file

    for /f "delims=" %%L in (foo.exe.config) do (
    
  3. Store the line

      set "Line=%%L"
    
  4. Do the replacement

      set "Line=!Line:Configuration\local.config=Configuration\production.config!"
    
  5. Output the line again

      echo !Line!
    )
    
Joey
  • 344,408
  • 85
  • 689
  • 683