Calling DOS batch Program or other programs?

This is a discussion on Calling DOS batch Program or other programs? within the C++ Programming forums, part of the General Programming Boards category; Is it possible to call a DOS batch program???If so how? Thanks alot...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    Calling DOS batch Program or other programs?

    Is it possible to call a DOS batch program???If so how?


    Thanks alot

  2. #2
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    Look up the system command.

    Code:
    /* system example : DIR */
    #include <stdio.h>
    #include <stdlib.h>
    
    int main ()
    {
      int i;
      puts ("Trying to execute command DIR");
      i = system ("dir");
      if (i==-1) puts ("Error executing DIR");
      else puts ("Command successfully executed");
      return 0;
    }
    Example taken from www.cplusplus.com

    It is of course possible just to use;
    system("dir"); // or in your case
    system("myprog.bat");

    But then you have no error checking. (Doesn't stop most people)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling one program from another program
    By arian in forum C# Programming
    Replies: 2
    Last Post: 09-19-2008, 09:25 AM
  2. Calling external program and reading its output.
    By Dragoon_42 in forum C++ Programming
    Replies: 3
    Last Post: 10-18-2007, 06:34 AM
  3. Calling delete Crashes my Program
    By thetinman in forum C++ Programming
    Replies: 19
    Last Post: 10-13-2007, 04:07 AM
  4. calling a program from a program
    By Waldo2k2 in forum C Programming
    Replies: 2
    Last Post: 01-20-2003, 01:43 PM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM

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