Thread: calling batch files

  1. #1
    Unregistered
    Guest

    Angry calling batch files

    I have recently completed a command line based (DOS) test automation system which consists of various batch files calling C programs. I am now attermpting to create a GUI wrapper for this system in C++ to make it more user friendly.

    I want to know whether you can call batch files through the 'system("batchfile")' function call ? If not the how do you call batch files from C programs ?

    bigSteve

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I want to know whether you can call batch files through
    >the 'system("batchfile")' function call
    You'd find out pretty quick if you tried it, wouldn't you?

    -Prelude
    My best code is written with the delete key.

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Why don't you try and find out yourself.
    What I know is that there are lot of ways to call batch files.
    For example: _execv, _execl, CreateProcess (this one is more difficult but very powerful).

  4. #4
    Unregistered
    Guest

    batch files

    Thankyou both for your 'useful' replies - makes me feel proud to be a member of the board.

    Seriously though, I have tried (of course) to call batch files like this: system("call batchfilename") BUT it does not work.

    Any other ideas ?

    bigSteve

  5. #5
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Keep trying because it should work...
    Code:
    system("C:\\test.bat arg1 arg2");
    This works fine on my machine.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Thankyou both for your 'useful' replies
    Perhaps you should do some research before asking a question then. You'll get fewer sarcastic remarks.

    >I have tried (of course) to call batch files like this: system("call
    >batchfilename") BUT it does not work.
    Because call is a batch command and system is a command line function. All you have to do is give system the path and file name of the batch file:
    system ( "C:\\SomeDirectory\\someBatch.bat" );

    And any arguments that it needs.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. batch file introduction in multiprocesses program
    By c_geek in forum C Programming
    Replies: 0
    Last Post: 03-27-2008, 01:52 PM
  2. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  3. Calling Audio/Graphic Files
    By pujuman in forum C++ Programming
    Replies: 9
    Last Post: 01-08-2005, 01:19 AM
  4. error with 2 header files calling each other
    By paperbox005 in forum C++ Programming
    Replies: 3
    Last Post: 10-06-2004, 02:36 AM