10ReturnCodes.bat
::This program is used to demonstrate the return statement ::Every comamnd or batch file returns an integer to indicate result of program :: if returned code is XERO, in general it is agreed as succesful execution :: in case of error it supposed to return NON-ZERO integer, to indicate error specific @echo off :: ERRORLEVEL is in-built variable which is popped up with return code from last executed command or program ping foo.com if %ERRORLEVEL%==0 (echo foo ping was successful) else (echo foo ping was having issue) ping google.com if %ERRORLEVEL%==0 (echo google ping was successful) else (echo google ping was having issue) echo "program will exit with 0 return code, after you press enter" pause ::at time of return, program should return with error code exit 0
Output
