Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!cjveenm From: cjveenm@cs.vu.nl (Veenman CJ) Newsgroups: comp.sys.ibm.pc Subject: Re: Can batch files return value to C program? Keywords: TurboC,Batch,ErrorLevel Message-ID: <6082@star.cs.vu.nl> Date: 22 Mar 90 12:43:18 GMT References: <2469@rodan.acs.syr.edu> <26029AB4.25754@maccs.dcss.mcmaster.ca> Sender: news@cs.vu.nl Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 19 In article <26029AB4.25754@maccs.dcss.mcmaster.ca> cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) writes: > 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. The reason you do a system () call is to let your shell use your PATH in finding the program you want to execute, but I can be wrong. In this case you can do a exec call and use your PATH yourself to find the program. Then _you_ will get the possible error code. In Turbo Pascal the procedure Exec can be used and in C something simalar might exist. I wrote a procedure to do this and it works. Cor.