Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Invoking A DOS Program Through A "C" Program

Reply
Thread Tools

Invoking A DOS Program Through A "C" Program

 
 
~neil~
Guest
Posts: n/a
 
      09-23-2004
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
 
Reply With Quote
 
 
 
 
Barry Schwarz
Guest
Posts: n/a
 
      09-24-2004
On 23 Sep 2004 14:25:39 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (~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>>
 
Reply With Quote
 
 
 
 
Neil Kurzman
Guest
Posts: n/a
 
      09-25-2004
The easiest is system()

as in :
sytem("Doscmd");

DOS really? I heard it was dead.

 
Reply With Quote
 
Mark F. Haigh
Guest
Posts: n/a
 
      09-25-2004
(E-Mail Removed) (~neil~) wrote in message news:<(E-Mail Removed). 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
(E-Mail Removed)
 
Reply With Quote
 
~neil~
Guest
Posts: n/a
 
      09-25-2004
(E-Mail Removed) (Mark F. Haigh) wrote in message news:<(E-Mail Removed) om>...
> (E-Mail Removed) (~neil~) wrote in message news:<(E-Mail Removed). 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
> (E-Mail Removed)


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

Neil
 
Reply With Quote
 
~neil~
Guest
Posts: n/a
 
      09-26-2004
(E-Mail 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
 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      09-26-2004
~neil~ <(E-Mail Removed)> scribbled the following:
> (E-Mail 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 ((E-Mail Removed)) ------------- 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
 
Reply With Quote
 
George Fulk
Guest
Posts: n/a
 
      09-28-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoking Firefox save as dialog through javascript Sampat Javascript 1 02-21-2008 09:49 AM
IOS DoS defense causes DoS to itself:) Igor MamuziŠ Cisco 2 05-19-2006 11:59 PM
Error invoking JVM through JNI Bruce Java 2 02-13-2006 09:29 PM
Unable to run MS-DOS in Windows and DOS properties tabs missing Don Computer Support 5 02-11-2004 07:20 PM
Executing DOS (yes, DOS) program from within Python? Ben Fairbank Python 2 10-07-2003 08:51 AM



Advertisments