title: Programmatically writing a batch file to echo to stderr
body: <p>As a part of some integration tests I am working on, I need to write a batch file that echoes out to stderr on a windows box.  Currently I am using the following command:</p>
  
  <pre><code>md %UserProfile%\tests\e3f949d1219d4cad9288bf88d0fcc906\ &amp;&amp; cd %UserProfile%\tests\e3f949d1219d4cad9288bf88d0fcc906\ &amp;&amp; ( echo @echo off  &amp;&amp; echo 'echo This is error line 1 1&gt;&amp;2' &amp;&amp; echo 'echo This is error line 2 1&gt;&amp;2' &amp;&amp; echo @echo on ) &gt;&gt;test-stderrout.bat
  </code></pre>
  
  <p>This should create a temp directory under the <code>%UserProfile%\tests\</code> directory.  Then Navigate to this temp working directory.  Then create a batch file with the following code:</p>
  
  <pre><code>@echo off
  echo This is error line 1 1&gt;&amp;2
  echo This is error line 2 1&gt;&amp;2
  @echo on
  </code></pre>
  
  <p>However, instead the file contains:</p>
  
  <pre><code>@echo off
  @echo on
  </code></pre>
  
  <p>I see that the first echo gets piped out into stderr instead of reading that as text to then be in the batch file.  Is it possible to to escape this somehow to allow the output to contain the redirect statement?</p>