Invoking A DOS Program Through A "C" Program

Discussion in 'C Programming' started by ~neil~, Sep 23, 2004.

  1. ~neil~

    ~neil~ Guest

    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
     
    ~neil~, Sep 23, 2004
    #1
    1. Advertising

  2. On 23 Sep 2004 14:25:39 -0700, (~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>>
     
    Barry Schwarz, Sep 24, 2004
    #2
    1. Advertising

  3. ~neil~

    Neil Kurzman Guest

    The easiest is system()

    as in :
    sytem("Doscmd");

    DOS really? I heard it was dead.
     
    Neil Kurzman, Sep 25, 2004
    #3
  4. (~neil~) wrote in message news:<>...
    > 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
     
    Mark F. Haigh, Sep 25, 2004
    #4
  5. ~neil~

    ~neil~ Guest

    (Mark F. Haigh) wrote in message news:<>...
    > (~neil~) wrote in message news:<>...
    > > 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
    >


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

    Neil
     
    ~neil~, Sep 25, 2004
    #5
  6. ~neil~

    ~neil~ Guest

    (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 :)
     
    ~neil~, Sep 26, 2004
    #6
  7. ~neil~ <> scribbled the following:
    > (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 () ------------- 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
     
    Joona I Palaste, Sep 26, 2004
    #7
  8. ~neil~

    George Fulk Guest

    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.
     
    George Fulk, Sep 28, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce
    Replies:
    2
    Views:
    4,053
    Vitaly
    Feb 13, 2006
  2. Ben Fairbank
    Replies:
    2
    Views:
    5,469
  3. john san
    Replies:
    19
    Views:
    751
    Diez B. Roggisch
    Feb 18, 2005
  4. tomhr
    Replies:
    27
    Views:
    1,438
    Mike Wahler
    Jan 12, 2006
  5. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    294
    Michele Dondi
    Jan 22, 2004
Loading...

Share This Page