Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

C's system() & COMMAND.COM (Developers)

posted by nidud(R) E-mail, Norway, 13.09.2014, 14:54

> >
> > That all return codes from system() comes from %COMSPEC% and not from
> the
> > .COM/.EXE/.BAT files executed.
> That is exactly the problem I came with and posted about.
> Alex

My point was that those using the system function may expect COMSPEC to be executed in this case, and you mention a few of the (good) reasons why in point one in your first post. Other functions are normally used to call .EXE/.COM files directly.

I assume one way to get the return code using COMSPEC from .EXE/.COM files is to use a batch file.

COMMAND.COM will return an ?errorlevel? in INT 0x21/0x4D from a batch file, but not from an .EXE/.COM file.

COMMAND /C return9.exe -- returns 0


COMMAND /C exec.bat -- returns 9

        write(file,?%s\n?, command)
        return result


Complete thread:

Back to the forum
Board view  Mix view
15318 Postings in 1384 Threads, 254 registered users, 16 users online (0 registered, 16 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum