title: batch file echo on/off not working properly
body: <p>I'm not really used to making batch files, so I'm probably doing something wrong, but I'm really having trouble with echo off/on.  (That said, if you see any other error that I missed, feel free to point it out)</p>
  
  <p>Here's a simplified version of my code:</p>
  
  <pre><code>@echo off
  setlocal
  set args=
  set dir="."
  
  :getargs
  IF "%2"=="" (
      set dir="%1"
      goto callbatch
  )
  set args=%args% %1
  shift
  goto getargs
  
  :callbatch
  for %%f in (%dir%\*.txt) do (
      echo processing %%f
      "%BATCHHOME%\batch.bat %args% %%f
      echo
  )
  </code></pre>
  
  <p>So basically, I have a batch file in BATCHHOME that does something to a single txt file and I want to produce a batch file that will process all the txt files in a given directory.  The lone echo in the loop is to better illustrate the problem. </p>
  
  <p>Now, here's where I have a problem.  The output of this looks like: </p>
  
  <pre><code>processing foo\text1.txt
  some output from batch.bat
  ECHO is on.
  
  C:\somedir&gt;(
  echo processing foo\text2.txt
     "C:\the\path\of\batch.bat" the arguments here foo\text2.txt
  )
  ECHO is on.
  
  C:\somedir&gt;(
  echo processing foo\text3.txt
     "C:\the\path\of\batch.bat" the arguments here foo\text3.txt
  )
  ECHO is on.
  
  (etc)
  </code></pre>
  
  <p>Ok... I don't know why the batch file I'm calling turns echo on, but I didn't make it, so I'll just turn it back off each time!  I changed the last part to:</p>
  
  <pre><code>:callbatch
  for %%f in (%dir%\*.txt) do (
      echo processing %%f
      "%BATCHHOME%\batch.bat %args% %%f
      echo off
  )
  echo
  echo on
  echo
  echo Finished!
  </code></pre>
  
  <p>(Again, the two lone "echo" are there for debug) So now the output looks like this: </p>
  
  <pre><code>processing foo\text1.txt
  some output from batch.bat
  processing foo\text2.txt
  some output from batch.bat
  processing foo\text3.txt
  some output from batch.bat
  (etc.)
  ECHO is off.
  ECHO is on.
  Finished!
  </code></pre>
  
  <p>This would be almost perfect, but there's something a bit odd.  If echo is on, then why does it display "Finished!" instead of "echo Finished!"?  The bigger (but related) problem however is that when the batch file is done, I don't get my path displayed any more.  In other words, instead of having:</p>
  
  <pre><code>C:\Somedir&gt;_
  </code></pre>
  
  <p>I just get</p>
  
  <pre><code>_
  </code></pre>
  
  <p>I need to type "echo on" manually to get the path to show again.  Where did I go wrong?</p>
  
  <p>edit: Just to clarify, I am aware that "echo" by itself prints the current status of echo.  That is what I intended.  In the first code, they are there to show that echo mysteriously turns on after I call the other batch file.  In the second one, it is there to show that echo is on at the end of the batch file, yet the behaviour is as if it wasn't.  THAT is my problem.</p>