In Windows 2000 and newer, add:
|| GOTO :EOF
after each command that you want to check for failure.
If the command to the left of that fails, the batch file will quit/exit.
Two pipe symbols space GOTO space colon EOF
EOF stands for End Of File. You DO NOT need to create a label called EOF.
It is understood as the "end of your batch file".
Example:
DIR Q: || GOTO :EOF
TYPE FILENAME.EXT || GOTO :EOF
Austin M. Horst