Invoking A DOS Program Through A "C" Program

N

~neil~

hello

I'm fairly new to the language, and my problem is I'm trying to write
a program to run a command from the DOS prompt "C:>". I don't know all
the functions in "C", however there are a few under the header file
"process.h" that could be used, but I'm not really sure what they
mean. I only know them by their name <prototype declaration>. I don't
understand the arguments that are passed down to these functions, is
why I'm seeking help to write this small program.

Functions like: "spawnl", "spawnle", "spawnlvpe" or "execl" to make a
parent program invoke or run a child process program like "qbasic.exe"
for example. I set up the PATH statement <Enviroment Command> in the
autoexec.bat file in C directory to bring up the application from the
DOS prompt.

With my limited knowledge of pointers, I'm little unsure how this is
written in "C". Could anyone help me with the code for the program as
described here.

<Inside the Win32 console window>

Starting...
Running DOS Command. . .

Press any key to continue. . .


This is more advanced C programming....... I'm still learning:)

Thanks
Neil
 
B

Barry Schwarz

hello

I'm fairly new to the language, and my problem is I'm trying to write
a program to run a command from the DOS prompt "C:>". I don't know all
the functions in "C", however there are a few under the header file
"process.h" that could be used, but I'm not really sure what they
mean. I only know them by their name <prototype declaration>. I don't
understand the arguments that are passed down to these functions, is
why I'm seeking help to write this small program.

Functions like: "spawnl", "spawnle", "spawnlvpe" or "execl" to make a
parent program invoke or run a child process program like "qbasic.exe"
for example. I set up the PATH statement <Enviroment Command> in the
autoexec.bat file in C directory to bring up the application from the
DOS prompt.

With my limited knowledge of pointers, I'm little unsure how this is
written in "C". Could anyone help me with the code for the program as
described here.

The only portable/standard method is to use the system() function
which you can find in your C reference.
<Inside the Win32 console window>

Starting...
Running DOS Command. . .

Press any key to continue. . .

System specific questions should be taken to a system specific group,
in this case one of the many microsoft.public forums.


<<Remove the del for email>>
 
N

Neil Kurzman

The easiest is system()

as in :
sytem("Doscmd");

DOS really? I heard it was dead.
 
M

Mark F. Haigh

hello

I'm fairly new to the language, and my problem is I'm trying to write
a program to run a command from the DOS prompt "C:>". I don't know all
the functions in "C", however there are a few under the header file
"process.h" that could be used, but I'm not really sure what they
mean. I only know them by their name <prototype declaration>. I don't
understand the arguments that are passed down to these functions, is
why I'm seeking help to write this small program.

Functions like: "spawnl", "spawnle", "spawnlvpe" or "execl" to make a
parent program invoke or run a child process program like "qbasic.exe"
for example. I set up the PATH statement <Enviroment Command> in the
autoexec.bat file in C directory to bring up the application from the
DOS prompt.

Keep learning, you'll get the hang of it. You may want to find a
MSDOS newsgroup like comp.os.msdos.programmer.
With my limited knowledge of pointers, I'm little unsure how this is
written in "C". Could anyone help me with the code for the program as
described here.

Try the following program. The system() function is the only thing
standard C has to say about this kind of thing.


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
system("cls");
return 0;
}


Does your screen clear when you run it? If so, simply replace "cls"
with the command you'd like to run.


Mark F. Haigh
(e-mail address removed)
 
N

~neil~

Keep learning, you'll get the hang of it. You may want to find a
MSDOS newsgroup like comp.os.msdos.programmer.


Try the following program. The system() function is the only thing
standard C has to say about this kind of thing.


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
system("cls");
return 0;
}


Does your screen clear when you run it? If so, simply replace "cls"
with the command you'd like to run.


Mark F. Haigh
(e-mail address removed)

Yes, it does!! thanks alot..............I should of thought of that.

Neil
 
N

~neil~

(e-mail address removed) (Mark F. Haigh) wrote in message >
Keep learning, you'll get the hang of it. You may want to find a
MSDOS newsgroup like comp.os.msdos.programmer.

Funny you mentioned that........:) See my other post O.K

<titled>
"Isn't C programming under DOS part of this Newsgroup"

Neil :)
 
J

Joona I Palaste

~neil~ said:
(e-mail address removed) (Mark F. Haigh) wrote in message >
Keep learning, you'll get the hang of it. You may want to find a
MSDOS newsgroup like comp.os.msdos.programmer.
Funny you mentioned that........:) See my other post O.K
<titled>
"Isn't C programming under DOS part of this Newsgroup"

It depends. Standard C programming is part of this newsgroup no matter
what operating system you use. But DOS-specific programming isn't part
of this newsgroup any more than, say, Unix-specific programming is. No
one is going to flame you simply because you compile and run your C
programs under DOS. But if you think this means we'll answer questions
about creating DOS processes, interfacing with parallel/serial ports,
switching screenmodes or something, then the answer is no. You'll be
better off asking those questions on comp.os.msdos.programmer.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'So called' means: 'There is a long explanation for this, but I have no
time to explain it here.'"
- JIPsoft
 
G

George Fulk

Caution if you are using a Borland C compiler. The Borland C libraries
for all the "exec" type functions have a (IMHO show-stopping) bug, where
it might corrupt your image after it's loaded into memory. MS or Watcom
should work fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top