Running MS-DOS within a c++ program (Code)

M

Mike

What i want to do is have my c++ program, run a DOS program and copy a
script from that DOS program to a file. I simply have no idea, how, or
if it's plausable, to run DOS within a c++ program. It's a command
prompt, within a command prompt. Any input would be great.

Thanks
Brune
 
A

Alf P. Steinbach

* Mike:
What i want to do is have my c++ program, run a DOS program and copy a
script from that DOS program to a file.

I simply have no idea, how, or
if it's plausable, to run DOS within a c++ program. It's a command
prompt, within a command prompt. Any input would be great.

Off topic.

Try over in [comp.os.ms-windows.programmer.win32].
 
S

Shark

Alf said:
* Mike:
What i want to do is have my c++ program, run a DOS program and copy a
script from that DOS program to a file.

I simply have no idea, how, or
if it's plausable, to run DOS within a c++ program. It's a command
prompt, within a command prompt. Any input would be great.

Off topic.

Try over in [comp.os.ms-windows.programmer.win32].

Can he not try the system() function?
 
K

Kai-Uwe Bux

Mike said:
What i want to do is have my c++ program, run a DOS program and copy a
script from that DOS program to a file. I simply have no idea, how, or
if it's plausable, to run DOS within a c++ program. It's a command
prompt, within a command prompt. Any input would be great.

As far as standard C++ is concerned, the std::system() function from
<cstdlib> seems to be the only way to call another program from within C++.
Maybe, something like

std::system( "my_program.exe > my_file.script" );

works on your platform -- but that is just a wild guess.

If that does not work for you, you may want to resort to the use of
(platform specific) 3rd party libraries, which are, however, off-topic in
this group.


Best

Kai-Uwe Bux
 
P

Peter_Julian

| Alf P. Steinbach wrote:
| > * Mike:
| > > What i want to do is have my c++ program, run a DOS program and
copy a
| > > script from that DOS program to a file.
| > >
| > > I simply have no idea, how, or
| > > if it's plausable, to run DOS within a c++ program. It's a
command
| > > prompt, within a command prompt. Any input would be great.
| >
| > Off topic.
| >
| > Try over in [comp.os.ms-windows.programmer.win32].
| >
|
| Can he not try the system() function?
|

system() is not part of the standard, hence off topic. The rule is if it
only runs on Windows (or if it only runs on any other OS), then its
probably off topic here. The C++ community expends a great deal of
effort to provide a standard that applies to any OS, including those
that are yet to be invented.
 
A

Alf P. Steinbach

* Peter_Julian:
system() is not part of the standard, hence off topic. The rule is if it
only runs on Windows (or if it only runs on any other OS), then its
probably off topic here. The C++ community expends a great deal of
effort to provide a standard that applies to any OS, including those
that are yet to be invented.

You mean, system() is part of the standard, but any particular use of it
is not.

In addition to your comments, I don't think the system() function would
solve the OP's problem. But I could be wrong. The problem was not very
clearly explained.
 
G

Gavin Deane

Peter_Julian said:
| Alf P. Steinbach wrote:
| > * Mike:
| > > What i want to do is have my c++ program, run a DOS program and
copy a
| > > script from that DOS program to a file.
| > >
| > > I simply have no idea, how, or
| > > if it's plausable, to run DOS within a c++ program. It's a
command
| > > prompt, within a command prompt. Any input would be great.
| >
| > Off topic.
| >
| > Try over in [comp.os.ms-windows.programmer.win32].
| >
|
| Can he not try the system() function?
|

system() is not part of the standard, hence off topic. The rule is if it
only runs on Windows (or if it only runs on any other OS), then its
probably off topic here. The C++ community expends a great deal of
effort to provide a standard that applies to any OS, including those
that are yet to be invented.

system() is entirely standard. Before calling system("send this to the
command processor") you can find out whether a command processor is
available.

I believe that is done by calling system(0) which return non-zero if a
command processor is present, zero otherwise. But I don't have a
definitive C library reference to hand to be absolutely sure.

Of course, how the command processor on a particular platform behaves
in response to any particular command is outside the scope of standard
C++.

Gavin Deane
 
M

Mike

Thanks for the input, I apologize if this is off topic, I understand
the basic idea of the system function, though it doesn't allow me to
access specific executables within specific directories. Or if it does
i haven't discovered how to do that yet. I beleive that if I could
access my executable then it would work. But i can't seem to access
the proper executable. Any more ideas are great. Thanks for the input
thus far. Again sorry this is off topic

Brune
 

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,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top