[comp.lang.c] Creating a NEW DOS SHELL from MSC 4.00

buwyatt%brock.cdn%ubc.csnet@RELAY.CS.NET (Jamie Wyatt) (09/04/87)

I am working on a project and I wish to allow the user to spawn
to the dos shell to allow the use of DOS commands then
when finished type 'EXIT' and return to my application.

I have it working but the DOS environment is destroyed. Anything
that was set before my program is called is OK but the remainder
of the environment is destroyed (filled with garbage) so that 
no further 'sets' can be performed.

This is  a sample of what I did to get the shell up:

buwyatt%brock.cdn%ubc.csnet@RELAY.CS.NET (Jamie Wyatt) (09/04/87)

I am working on a project and I wish to allow the user to spawn
to the dos shell to allow the use of DOS commands then
when finished type 'EXIT' and return to my application.

I have it working but the DOS environment is destroyed. Anything
that was set before my program is called is OK but the remainder
of the environment is destroyed (filled with garbage) so that 
no further 'sets' can be performed.

This is  a sample of what I did to get the shell up:

*
*
char comspec [65];
*
*
*
* 
strcpy (comspec, getenv("COMSPEC"));
*
spawnlp (P_WAIT, comspec, comspec, NULL);
*
*
*

Once in the new DOS shell any set ... returns the environment full
error and if set is typed the following is displayed:

C> set
COMSPEC=C:\COMMAND.COM
PATH=C:\DOS;C:\UTIL;C:\LAVA
PROMPT=$p $n$g
;C_FILE_INFO........more garbage

Is this a bug in MSC 4.00 or am I doing something wrong?

Thanx
Jamie Wyatt

P.S. Sorry for the double message, the first message got trashed somehow!

jm@njitsc1.njit.edu (Joe Mucchiello) (09/08/87)

In MSC 4.0, if I remember correctly, you #include <system.h>
and then do a system("command"); to activate a true ms-dos shell.

--jm