use ERRORLEVELto check the exit code of the previous command:
if ERRORLEVEL 1 exit /b
EDIT: : " , EQUAL GREATER, X" ( if /?). ,
if exist foo.txt echo yada yada
, :
if ERRORLEVEL 1 ( echo error in previous command & exit /b )
if ERRORLEVEL 1 (
echo error in previous command
exit /b
)