C++ code for running dos programs

This is a discussion on C++ code for running dos programs within the C++ Programming forums, part of the General Programming Boards category; I know there is a piece of code that allows you to run a dos program, but I can't rember ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    6

    C++ code for running dos programs

    I know there is a piece of code that allows you to run a dos program, but I can't rember what it is. I want to run a program that will tell a dos bat file to run. can anyone help me???

  2. #2
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    one way I can think of is:
    Code:
    system("path\\to\\bat");

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    this is the code i usually use to run an exe (if i'm using a system call):
    Code:
    system("start \"[TITLE]\" [PATH] /B");
    ...or were you saying that you wanted to run something like command.com and then pass a batch file to it?

    edit: don't forget about the escape sequences, as pointed out by the above post
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    6

    yes to run a bat file

    and how do I initiate a your system command. What lib is it in??? I am a student, and am just learning. My teacher couldn't remember the command. I'd appreciate assistance. I have a program that is outputting data to a text file, and then I have a bat file that tells the computer to print the text file to the local printer. How can I tell the program to run the bat file.
    Last edited by danielp; 10-29-2003 at 09:12 PM.

  5. #5
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    Here.
    The header file is stdlib
    to run a bat file in your program add this line somewhere in your code:
    Code:
    system("c:\\mybatfile.bat");
    replace "c:\\mybatfile.bat" with the path to your bat file, and don't forget to use \\ instead of just one \
    hth

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 01:48 AM
  2. keyboard stop working at Dos
    By arian in forum C++ Programming
    Replies: 1
    Last Post: 11-18-2004, 02:32 PM
  3. << !! Posting Code? Read this First !! >>
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 10-03-2002, 04:04 PM
  4. Replies: 8
    Last Post: 07-20-2002, 10:23 AM
  5. code to run (linux) programs WITH arguments
    By N8760 in forum C++ Programming
    Replies: 3
    Last Post: 12-27-2001, 03:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21