Computing.Net > Forums > Programming > Executing DOS commands in C++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Executing DOS commands in C++

Reply to Message Icon

Name: iN3cRiPT
Date: June 24, 2003 at 10:07:05 Pacific
OS: Windows XP Pro
CPU/Ram: 2.4 GHz, OCd to 2.8, 1 gi
Comment:

ok guys, here is a question i have for you, if i want to execute dos commands in c++, what would i use? i'd really appreciate if you could answer this question, as batch files don't do everything i need (being a network admin with new computers every day). If you could please help me out... please do so :). also, i'm looking for a free/cheap c++ compiler thanks in advance :)



Sponsored Link
Ads by Google

Response Number 1
Name: micah
Date: June 24, 2003 at 10:40:49 Pacific
Reply:

I believe you can use the system(); function. For a free compiler check these out:

http://www.gnu.org/software/gcc/gcc.html
http://www.bloodshed.net/
http://www.capitalware.biz/pc_win_dev.html

-Micah
www.forevercode.cjb.net


0

Response Number 2
Name: iN3cRiPT
Date: June 24, 2003 at 10:48:39 Pacific
Reply:

Thanks alot for the compilers and the System() code, but being that i'm quite new to c++, how exactly would i use this... thanks for that comment, and thx in advance if you comment again :)


0

Response Number 3
Name: micah
Date: June 24, 2003 at 10:53:30 Pacific
Reply:

Here's an example in the help I found. Basically all you do is put in your dos command and it will print out the output.

/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/

#include <process.h>

void main( void )
{
system( "type system.c" );
}


0

Response Number 4
Name: Infinite Recursion
Date: June 24, 2003 at 12:25:22 Pacific
Reply:

Micah,

What compiler are you using?

Infinite Recursion


0

Response Number 5
Name: micah
Date: June 24, 2003 at 12:40:24 Pacific
Reply:

I use VC++ 6.0, but I also just got Dev-C++ to play around with.

-Micah


0

Related Posts

See More



Response Number 6
Name: kev
Date: June 24, 2003 at 17:41:59 Pacific
Reply:

The way I do it is this:

system("PAUSE");

All this would do is display the message "Please press any key to continue..." in the console window, as if I actually typed 'PAUSE' into a DOS line.

Kevin.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Executing DOS commands in C++

DOS commands in C www.computing.net/answers/programming/dos-commands-in-c/9449.html

"TYPE" DOS commands in C www.computing.net/answers/programming/type-dos-commands-in-c-/16874.html

run dos command in vb www.computing.net/answers/programming/run-dos-command-in-vb/121.html