The following list shows each exit code and a brief description of its
meaning:
0
Files were copied without error.
1
No files were found to copy.
2
The user pressed CTRL+C to terminate XCOPY.
4
Initialization error occurred. There is not enough memory or disk space,
or you entered an invalid drive name or invalid syntax on the command
line.
5
Disk write error occurred.
from Dos 6.22 help file which is the best reference for exit codes.
===> Since it would seem to divert from reality when the command is run on
an NT box (apparently, I have not tried it), one would have to come to the
conclusion that the DOS 6.22 help file might not contain the definitive exit
error code list for operating system versions that had not yet been
invented, *OR* that it simply applies only to dos 6.22.
/Al
--
----------------------------------------------------------
http://www.g2mil.com/Dec2003.htm
Michael D. Ober said:
I used %errorlevel% in MS-DOS 5. You have to check your errorlevels in
descending order as the example below shows. That said, there may be a bug
in XCOPY. Also, MS never really documented the error levels returned by
their utilities.
Mike Ober.
Thanks for the suggestions.
Is it true that the %errorlevel% usage is an NT improvement that is not
available under Win98?
Apparently, despite the clear statement in the help for Xcopy,
it never, under any circumstances, returns an errorlevel of 1.
Pity. I, for one, would find it useful.
Steve
Al Dunbar [MS-MVP] wrote:
:: :::
::: Major Ninth wrote:
::::: did you use ERRORLEVEL or %ERRORLEVEL% ?
::::: -john
:::::
::: I used the standard syntax.
::
:: Seems like standard DOS-based batch syntax - see suggestions below...
::
::: I've tried it with nonexistent directories
::: and empty directories. None of my tests gave me an errorlevel of 1.
::: Here's my test file:
:::
::: @setlocal
::: if %1. == . goto needdir
::
:: or:
::
:: if "%1" EQU "" goto:needdir
::
::: @if exist i:\not_now.text goto notnow
:::
::: xcopy i:\esprel %1 /r /c /l /d /exclude:i:\esprel\excludelist.txt
::: temp.txt
::
:: or replace these lines:
::
::: @if errorlevel 5 goto e5
::: @if errorlevel 4 goto e4
::: @if errorlevel 2 goto e2
::: @if errorlevel 1 goto e1
::: @if errorlevel 0 goto e0
:::: e5
::: @echo errorlevel 5
::: @goto end
:::: e4
::: @echo errorlevel 4
::: @goto end
:::: e2
::: @echo errorlevel 2
::: @goto end
:::: e1
::: @echo errorlevel 1
::: @goto end
:::: e0
::: @echo errorlevel 0
::: @goto end
::
:: with these lines:
::
:: @echo errorlevel is %errorlevel%
:: @goto:eof
::
:::
:::
:::: needdir
::: @echo off
::: @echo test message
::: @goto end
:::
:::: notnow
::: @type i:\not_now.text
:::
:::: end
::
:: Don't need a :end label, as :eof is implicitly there.
::
:: /Al