Path: utzoo!attcan!lsuc!maccs!cs4g6ag From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Newsgroups: comp.sys.ibm.pc Subject: Re: Can batch files return value to C program? Keywords: TurboC,Batch,ErrorLevel Message-ID: <26029AB4.25754@maccs.dcss.mcmaster.ca> Date: 17 Mar 90 20:14:43 GMT References: <2469@rodan.acs.syr.edu> Reply-To: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Organization: McMaster University, Hamilton, Ontario Lines: 23 In article <2469@rodan.acs.syr.edu> jfbruno@rodan.acs.syr.edu (John F. Bruno) writes: $I calling a batch file using the Turbo-C system() call. Is there a way $to get the value of "ERRORLEVEL" upon returning to the Turbo-C program? $system() is declared as an int, but it only returns 0 or -1, I believe $it returns -1 only if it couldn't find COMMAND.COM (and maybe -1 if the $batch file wasn't found, but I haven't tested it for that) I can't set $an environment variable in the batch file because when I return to the $calling program, that environment is gone. Please note that a batch file can not return an errorlevel at all. Only .COM and .EXE programs return errorlevels, and to get their return codes they can not be executed using the system () call, since that invokes COMMAND.COM first and COMMAND.COM doesn't pass back the errorlevel of any program it spawns. There are programs that can update copies of the environment table other than their own; you may want to get your hands on one or two of those and see if you can implement some form of return codes using them. -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca = "\nI'm only an undergraduate!!!\n"; **************************************************************************** "So sorry, I never meant to break your heart ... but you broke mine."