Running programs

This is a discussion on Running programs within the C++ Programming forums, part of the General Programming Boards category; How can I run programs from an executable, and then close my program? I.e.: -my program opens -runs program one ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    417

    Running programs

    How can I run programs from an executable, and then close my program?

    I.e.:

    -my program opens
    -runs program one
    -immediately runs program two
    -returns 0

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    How you do this depends on your platform. Windows boxes can use ShellExecute or anything similar while Unix or Linux boxes would generally turn to the exec family of functions. A last resort option is the standard system function, but despite being available on all implementations, this function offers little in the way of advantages over less portable choices.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    I'm using windows

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    Sorry about the double post...

    How do I use ShellExecute?

    Code:
    HINSTANCE ShellExecute(          HWND hwnd,
        LPCTSTR lpOperation,
        LPCTSTR lpFile,
        LPCTSTR lpParameters,
        LPCTSTR lpDirectory,
        INT nShowCmd
    );

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    >>How do I use ShellExecute?
    By visiting MSDN and reading the documentation and examples. Otherwise, why are they there?

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    I screwed around, and I almost got it working.

    Code:
    	ShellExecute (NULL, "open", "C:\\Program Files\\Stardock\\ObjectBar\\ObjectBar.exe", NULL, NULL, 0);
    	ShellExecute (NULL, "open", "C:\\Program Files\\Stardock\\DesktopX\\DesktopX.exe", NULL, NULL, 0);
    	return 0;
    The problem is that it doesn't act like I opened it from the run dialog or the start menu... it pops up a window when normally it goes to the systray

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    Nevermind...

    Code:
    	ShellExecute (NULL, "open", "C:\\Program Files\\Stardock\\ObjectBar\\ObjectBar.exe", NULL, 
    		"C:\\PROGRA~1\\Stardock\\OBJECT~1", 0);
    	ShellExecute (NULL, "open", "C:\\Program Files\\Stardock\\DesktopX\\DesktopX.exe", NULL, 
    		"C:\\PROGRA~1\\Stardock\\DesktopX", 0);
    	return 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  2. Monitor That Another App is Running
    By CodeButcher in forum Windows Programming
    Replies: 1
    Last Post: 01-18-2007, 01:34 PM
  3. Newbie question: pointers, other program's memory
    By xxxxme in forum C++ Programming
    Replies: 23
    Last Post: 11-25-2006, 01:00 PM
  4. help with running programs with c++
    By mendel69 in forum C++ Programming
    Replies: 5
    Last Post: 10-12-2006, 08:50 AM

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