Skip to content

Instantly share code, notes, and snippets.

@syl20bnr
Created Dec 12, 2012
Embed
What would you like to do?
robocopy exit codes suck :-)
rem -------------------------------------------------------------------------------
rem this file controls the error level returned by the tool robocopy in order to
rem be usable in a custom build step of Visual Studio
rem -------------------------------------------------------------------------------
robocopy.exe /A-:R /NP /NJH /NJS /NDL /NFL /NS /NC %*
rem if errorlevel 16 echo Robocopy Exit Status: ***FATAL ERROR*** & exit /b 1
rem if errorlevel 15 echo Robocopy Exit Status: FAIL MISM XTRA COPY & exit /b 1
rem if errorlevel 14 echo Robocopy Exit Status: FAIL MISM XTRA & exit /b 1
rem if errorlevel 13 echo Robocopy Exit Status: FAIL MISM COPY & exit /b 1
rem if errorlevel 12 echo Robocopy Exit Status: FAIL MISM & exit /b 1
rem if errorlevel 11 echo Robocopy Exit Status: FAIL XTRA COPY & exit /b 1
rem if errorlevel 10 echo Robocopy Exit Status: FAIL XTRA & exit /b 1
rem if errorlevel 9 echo Robocopy Exit Status: FAIL COPY & exit /b 1
rem if errorlevel 8 echo Robocopy Exit Status: FAIL & exit /b 1
rem if errorlevel 7 echo Robocopy Exit Status: MISM XTRA COPY OK & exit /b 0
rem if errorlevel 6 echo Robocopy Exit Status: MISM XTRA OK & exit /b 0
rem if errorlevel 5 echo Robocopy Exit Status: MISM COPY OK & exit /b 0
rem if errorlevel 4 echo Robocopy Exit Status: MISM OK & exit /b 0
rem if errorlevel 3 echo Robocopy Exit Status: XTRA COPY OK & exit /b 0
rem if errorlevel 2 echo Robocopy Exit Status: XTRA OK & exit /b 0
rem if errorlevel 1 echo Robocopy Exit Status: COPY OK & exit /b 0
rem if errorlevel 0 echo Robocopy Exit Status: --no change-- & exit /b 0
if errorlevel 16 exit /b 1
if errorlevel 15 exit /b 1
if errorlevel 14 exit /b 1
if errorlevel 13 exit /b 1
if errorlevel 12 exit /b 1
if errorlevel 11 exit /b 1
if errorlevel 10 exit /b 1
if errorlevel 9 exit /b 1
if errorlevel 8 exit /b 1
if errorlevel 7 exit /b 0
if errorlevel 6 exit /b 0
if errorlevel 5 exit /b 0
if errorlevel 4 exit /b 0
if errorlevel 3 exit /b 0
if errorlevel 2 exit /b 0
if errorlevel 1 exit /b 0
if errorlevel 0 exit /b 0
@vdepagter

This comment has been minimized.

Copy link

@vdepagter vdepagter commented May 22, 2014

rem Simpli.fy!
if errorlevel geq 8 exit /b 1
exit /b 0

@jowave

This comment has been minimized.

Copy link

@jowave jowave commented Feb 5, 2016

if errorlevel geq 8 exit /b 1 is wrong. Use:

if errorlevel 8 exit /b 1
exit /b 0

or

if %errorlevel% geq 8 exit /b 1
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment