title: Echo of String with Double Quotes to Output file using Windows Batch
body: <p>I'm attempting to rewrite a configuration file using a Windows Batch file.
  I'm looping through the lines of the file and looking for the line that I want to replace with a specified new line.</p>
  
  <p>I have a 'function' that writes the line to the file</p>
  
  <pre><code>:AddText %1 %2
  set Text=%~1%
  set NewLine=%~2%
  echo "%Text%" | findstr /C:"%markerstr%" 1&gt;nul
  if errorlevel 1 (
    if not "%Text%" == "" (
        setlocal EnableDelayedExpansion
        (
            echo !Text!
        ) &gt;&gt; outfile.txt
    ) else (
       echo. &gt;&gt; outfile.txt
    )
  ) else (
    set NewLine=%NewLine"=%
    setlocal EnableDelayedExpansion
    (
        echo !NewLine!
    ) &gt;&gt; outfile.txt
  
  )
  exit /b 
  </code></pre>
  
  <p>The problem is when %Text% is a string with embedded double quotes.
  Then it fails.  Possibly there are other characters that would cause it to fail too.
  How can I get this to be able to work with all text found in the configuration file?</p>