title: Hiding error messages if writing to a file fails in a Windows .BAT script
body: <p>i just subscribe here.</p>
  <p>I would want to hide the &quot;Acces is denied.&quot; error message in case writing to a read-only file fails. Could someone tell me why the following code doesn't work as expected ? I'm using Windows 10.</p>
  <pre><code>:: This file is assumed to be read-only.
  echo( &gt;&quot;MyReadOnlyFile.txt&quot; 2&gt;nul
  ( echo( ) &gt;&quot;MyReadOnlyFile.txt&quot; 2&gt;nul
  </code></pre>
  <p>In both case the &quot;Access is denied.&quot; message is displayed, although the following &quot;How-to: Redirection&quot; page at SS64 says the contrary: <a href="https://ss64.com/nt/syntax-redirection.html" rel="nofollow noreferrer">https://ss64.com/nt/syntax-redirection.html</a></p>
  <pre><code>Redirect to NUL (hide errors)
  command &gt;filename 2&gt; nul  Redirect output to file but suppress error
  (command)&gt;filename 2&gt; nul  Redirect output to file but suppress CMD.exe errors
  </code></pre>
  <p>Thanks in advance for your help.</p>
  <p>Lionel.</p>