Thread: Alternate System(); Command

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    10

    Alternate System(); Command

    Is there a way in C to execute a statement (for example, another .exe file) without using system();?

    I want it to execute the program, which will open another .exe, and then terminate. System(); waits for the program to end before the program terminates. Is there a way around waiting for the program to terminate?

    - Mellowz

  2. #2
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    Check out the exec() family of calls (exec(), execl(), execlp, ...).
    Insert obnoxious but pithy remark here

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    Thank you.

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    Okay, thanks for the FAQ about it, but whenever I use one of those commands, no new program pops up. The only one it works with for me is the system(); command. Any idea's why?

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    whenever I use one of those commands, no new program pops up. The only one it works with for me is the system(); command. Any idea's why?
    Post your code.

    It shouldn't open a new window anyway, but open it in the same window.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    No need to. I finally got it to work. Turns out you can use the system(); command and not have to wait for it to complete it's task.

    Code:
    char cmd[50];
    sprintf(cmd, "start \"path_to_program\"");
    system(cmd);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables within system command?
    By moagim in forum C++ Programming
    Replies: 22
    Last Post: 10-09-2006, 10:42 AM
  2. Help on System Command
    By Smoki in forum C++ Programming
    Replies: 5
    Last Post: 12-14-2005, 06:47 PM
  3. Problem using system() command.
    By mmongoose in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2005, 08:44 PM
  4. System() command opens a dos-box
    By phil_drew in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2004, 07:43 AM
  5. IDEA: Customizeable command system
    By Inquirer in forum Contests Board
    Replies: 1
    Last Post: 10-02-2002, 10:17 PM