By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,013 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,013 IT Pros & Developers. It's quick & easy.

Invoking A DOS Program Through A "C" Program

P: n/a
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
Nov 14 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On 23 Sep 2004 14:25:39 -0700, ne*********@hotmail.com (~neil~) wrote:
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>>
Nov 14 '05 #2

P: n/a
The easiest is system()

as in :
sytem("Doscmd");

DOS really? I heard it was dead.

Nov 14 '05 #3

P: n/a
ne*********@hotmail.com (~neil~) wrote in message news:<49**************************@posting.google. com>...
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
mf*****@sbcglobal.net
Nov 14 '05 #4

P: n/a
mf*****@sbcglobal.net (Mark F. Haigh) wrote in message news:<f8*************************@posting.google.c om>...
ne*********@hotmail.com (~neil~) wrote in message news:<49**************************@posting.google. com>...
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
mf*****@sbcglobal.net


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

Neil
Nov 14 '05 #5

P: n/a
mf*****@sbcglobal.net (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 :)
Nov 14 '05 #6

P: n/a
~neil~ <ne*********@hotmail.com> scribbled the following:
mf*****@sbcglobal.net (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 (pa*****@cc.helsinki.fi) ------------- 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
Nov 14 '05 #7

P: n/a
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.
Nov 14 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.