title: Batch File Success and Error logging
body: <p>Is there a way, within a batch file, to log the error and success of the batch file?</p>
  
  <p>I am trying to copy a file from my computer to 200 machines (works great) but want to know which fail and the reason it fails (because the screens go away really quick).</p>
  
  <pre><code>@echo off
  if [%1]==[] goto usage
  @echo mapping l: to %1\c$
  net use * /delete /y
  net use l: \\%1\c$ password /user:%1\administrator
  
  if ERRORLEVEL 1 (
  echo failed
  
   net use l: \\%1\c$ password /user:%1\administrator
  
  ) else (
  goto mappingError
  
  ) &gt; command.txt
  </code></pre>
  
  <p>::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</p>
  
  <pre><code>@echo copying link file to C: Drive
  copy "c:\_\CopyFileToHost\logoff.cmd" l:\
  </code></pre>
  
  <p>::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</p>
  
  <pre><code>@echo deleting l: mapping
  net use l: /delete /y
  
  @echo off
  goto :eof
  
  :usage
  @echo Usage: %0 hostname
  exit /B 1
  
  :mappingError
  @echo Error mapping remote drive, exiting
  exit /B 1
  </code></pre>