Xref: utzoo comp.sys.ibm.pc:23719 comp.lang.c:15774 Path: utzoo!utgpu!attcan!uunet!lll-winken!ames!oliveb!amdahl!drivax!alexande From: alexande@drivax.DRI (Mark Alexander) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: system() always returns 0? Summary: possible solution Keywords: MSC5.0 Message-ID: <4180@drivax.DRI> Date: 24 Jan 89 17:56:20 GMT References: <782@hawkmoon.MN.ORG> Reply-To: alexande@drivax.UUCP (Mark Alexander) Organization: Bob-ist Temple of Monterey Lines: 17 One possible solution to the problem of COMMAND.COM always returning zero is that used by NDMAKE. The basic idea is to construct on the fly a little batch file that gets passed to COMMAND.COM. Before you call system(), though, you create a little zero-length temporary file. The batch file runs the subprogram, then checks the errorlevel. If the errorlevel is 0, it deletes the temporary file. Then the main program gets control again and checks the existence of the temporary file: if it still exists, an error occurred. The batch file would look something like this: prog [parms...] [outfile] if errorlevel 1 goto done del tempfile :done -- Mark Alexander (amdahl!drivax!alexande)