title: Was ECHO ON or OFF when my Windows .bat was CALLed?
body: <p>When I <code>CALL</code> one Windows <code>.bat</code> file from another, can the called file tell whether <code>ECHO</code> was <code>ON</code> or <code>OFF</code> in the caller?</p>
  
  <p>When a <code>.bat</code> file is entered, <code>ECHO</code> is set to <code>ON</code> (even if it was <code>OFF</code> in the CALLER).</p>
  
  <p>I want to preserve the caller's <code>ECHO</code> <code>status</code> in the called <code>.bat</code> so I can control both (possibly a chain of more than two nested calls) from a single place.</p>
  
  <p>I could pass a parameter or set my own environment variable but is there a better way?</p>
  
  <p><strong>EDIT</strong>
  Just to clarify what's needed:
  callee.cmd needs to do things with echo off only for the duration of its run. Upon returning to its caller, it must restore the echo state the caller had.</p>
  
  <p>Please fill in the ?????s in the script below:</p>
  
  <p>callee.cmd:</p>
  
  <pre><code>@rem save the echo state
  @ ???? HOW???? ????
  @ set "savedEchoState=??????"
  
  @rem the following commands must not be echoed
  @echo off
  command1
  command2
  command3
  
  @rem restore the previous echo state
  echo %savedEchoState%
  </code></pre>
  
  <p>caller1.cmd:</p>
  
  <pre><code>@echo off
  call callee.cmd
  echo
  </code></pre>
  
  <p>caller2.cmd:</p>
  
  <pre><code>@echo on
  call callee.cmd
  echo
  </code></pre>
  
  <p>Required output:</p>
  
  <p>caller1.cmd must print <code>echo off</code> and caller2.cmd must print <code>echo on</code>.</p>
  
  <p>Can it be done <strong>without creating any files on a disk</strong>?</p>