title: capturing error message from echo in cmd prompt
body: <p>I'm writting out some text to a text file within a cmd batch script like such:</p>
  
  <pre><code>echo FlagValue=Y&gt;&gt;flag.txt
  </code></pre>
  
  <p>This normally works fine but occassionally if the text file is open by a different process, an error messgae is returned saying Access Denied. What I'd like to do is stop the batch file if an error occurs with something like:</p>
  
  <pre><code>if return_code GEQ 1 GOTO ERR
  </code></pre>
  
  <p>But can't find a return code from echo command. Does one exist, or is there a better tactic to use to capture error message?</p>