If emacs is running in batch and an error occurs then it does not exit with error status if debug-on-error is t. If debug-on-error is nil then emacs exits with error status (which I think is correct). To demonstrate this open the attached file and evaluate the comment lines with compilation-start. In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600) of 2008-08-10 Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include -fno-crossjumping'