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

exec.bat:
return9.exe

COMMAND /C exec.bat -- returns 9

System(command):
        create(%TEMP%\exec.bat)
        write(file,?%s\n?, command)
        close(file)
        execute(file)
        getresult()
        delete(file)
        return result

 

Complete thread:

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