xcopy completed successfully, but triggered an error
<p>I have a batch script to copy files from one disk to another using the xcopy command and I'm logging its results/process to a log file.  </p>

<p>When it logs failures, I'm using the double pipe ('||') so that if the command returns anything except an error code of 0 it will trigger my error handling.  </p>

<p>My problem is I logged xcopy running successfully and copying all the files I asked it to.  I verified the copied files are good.  But for some reason it looks like it didn't return 0 and triggered my error handling.   I've copied and pasted this same script for other backups that work fine, but this one errored out on success, Why?</p>

<pre><code>mkdir %Disk%\"Report Archives" || goto FAILURE
xcopy "C:\NetworkBackups\Report Archives" %Disk%\"Report Archives" /E /H /C /I /R /Y &gt;&gt; %LogFile% || goto FAILURE

for /f "tokens=1" %%u in ('echo %time%') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set MilitaryTime=%t:~0,2%:%t:~3,2%:%t:~6,2%
echo %date:~10,4%/%date:~4,2%/%date:~7,2% %MilitaryTime%:  Done Copying "C:\NetworkBackups\Report Archives" to Monthly Backup disk: %Disk% &gt;&gt; %LogFile%

:FAILURE
echo %date:~10,4%/%date:~4,2%/%date:~7,2% %MilitaryTime%:  THIS BACKUP UP SCRIPT HAS ENCOUNTERED AN ERROR WITH THE PREVIOUS COMMAND. &gt;&gt; %LogFile%
</code></pre>

<p>Here is the end of the resulting log file:</p>

<pre><code>C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=91.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=92.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=93.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=94.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=95.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=96.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=97.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=98.html
C:\NetworkBackups\Report Archives\[redacted]\2011\2011.12.31 23.45\reports.asp@ReportID=99.html
388548 File(s) copied
2016/10/27 03:06:06:  THIS BACKUP UP SCRIPT HAS ENCOUNTERED AN ERROR WITH THE PREVIOUS COMMAND. 
</code></pre>

<p>I am not sure why the FAILURE label got triggered instead of logging "Done copying blah blah blah".  Also, note that this script will only run the FAILURE label when it gets told to GOTO it.  While not listed in my script you see here, the FAILURE gets skipped over when things run well.</p>