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 alexfru(R), USA, 13.09.2014, 01:00

> if you want to be compatible to Borland or Microsoft, system("command") is
> equivalent to %COMSPEC%/c command, and there is no errorlevel returned
> from the executed command available.

Some compilers' DOS-specific implementation system() goes a bit further and tries to make sense of the command by checking the extension (.COM, .EXE, etc), if any, and checking the command against a [naturally never complete and accurate] list of internal commands of COMMAND.COM. Basically, if it's a .COM/.EXE, "COMMAND.COM /C" is avoided and the program is executed directly, which lets one get its exit code instead of 0 from COMMAND.COM. That's what I'm doing now as well.

> that's the way it is (and saves you a lot of work ;)

It doesn't save my anything if I care about the outcome of the function call.



Complete thread:

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