![]() |
|
#1
|
|||
|
|||
Executing a program inside my programWhat I want to do is making a program, that when i run it, it will launch a few programs for me, like kazaa, msn, ie, my internet connection, ect. I already have all these lnk files ready, im just not sure how to make my program execute them.
Thanks for any help. |
|
#2
|
|||
|
|||
|
The C standard library function system() will execute a program, defined by its argument. Note control won't return to the calling program until the called program is finished.
I am assuming you are using some version of Windows. Here is something that I threw together that launches a text editor, gnuplot, dev-c++, and two Microsoft Word windows on my system. (Windows XP). This program compiles and executes OK with Borland or Visual C++ compilers. For gnu c compilers (dev-cpp, etc.) use forward slashes in the path names. CPP / C++ / C Code:
Note that for directories having spaces in their names, there are two ways to indicate the path: put quotes around each directory in the path that has a space, or use the "8.3" (DOS) version of the name. Here's how to find the "8.3" version of the name if your windows is installed on drive C: Open a command window (run cmd.exe from the start window). enter C: enter cd \ enter dir /x Then, among the stuff that comes out, you will see something like 08/02/2004 06:29 AM <DIR> PROGRA~1 Program Files PROGRA~1 is the "8.3" version of the name of the "Program Files" directory. Dave Last edited by davekw7x : 05-Aug-2004 at 15:12.
|
|
#3
|
|||
|
|||
|
ok, now lets say in beetween program one and 2, i want the computer to stop for 30 seconds, then execute program 2, is their anyway to get the program to stop, then continue?
Also, lets say i ran internet explorer, and im reading emails or what not and dont want to be disturbed by other programs poping up over it, is their anyway the program can run them under the ie window? |
|
#4
|
|||
|
|||
|
Quote:
I don't have a c-program to do this (people using Borland command-line compilers can try sleep(), in <dos.h>, but its use is deprecated). If you are running Windows XP, you can download the Windows Server 2003 Resource kit and use its sleep.exe function. go to http://www.microsoft.com/windowsserv...s/default.mspx then select "Windows Server 2003 Resource Kit Tools" to download. You don't have to be running Windows Server 2003 to use the sleep.exe; it's OK for Windows xp. Then, in your program you can say CPP / C++ / C Code:
to cause a 10 second delay between "foo" and "bar" execution. If you are on a Windows machine with gnu cywgin installed, it has a "sleep" function in its bin directory. Try this. Dave |
|
#5
|
|||
|
|||
|
um, so whats the start foo and bar?? Im new to this stuff so take it easy on me, lol.
|
|
#6
|
|||
|
|||
|
Sorry, it's kind of "inside" jargon to designate arbitrary programs, file names, etc. So instead of having to put real program names in there, or to use something unimaginative like XXX.exe or ABC.exe, we just use "foo" and "bar". You put whatever application program names that you are starting. You see this in lots of programming documentation and some books.
(The old military abbreviation FUBAR means F***** Up Beyond All Recognition; I think that's where someone got the idea for "foo" and "bar" some time ago.) Dave |
|
#7
|
||||
|
||||
|
I have always wondered about these 2 words too, so it's good to finally know where they came from. Thank you.
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#8
|
|||
|
|||
|
so...
CPP / C++ / C Code:
This correct?? Also is their anyway at the end of the program you can get it to start back at the start , like a restart of the program? Also, if i wante to have it run to differnt inetnet explorers, and I wanted 1 to stay on top, and the other to be executed in the background, without poping up, could this be done? |
|
#9
|
|||
|
|||
|
Quote:
Not this one: CPP / C++ / C Code:
In general, the command CPP / C++ / C Code:
launches the command, foo, and waits for its completion before returning to the calling program Fow Windows XP (and probably other Windows versions, too, but I don't have anything to test it with just now) the command. CPP / C++ / C Code:
launches the command, foo, and returns immediately to the calling program. You want the start for programs that are going to remain running, but not for the sleep(). Try the following (assuming you have the program sleep somewhere on your path, otherwise --- include the path in the argument): CPP / C++ / C Code:
Then try it again with the system() commands in the other order. Also, you can investigate the standard C function spawnl(). It includes an argument that can tell it whether to wait for completion or not. Quote:
I'm not sure what you mean. You could, of course, make a loop CPP / C++ / C Code:
Quote:
I don't know. Sorry. Regards, Dave |
|
#10
|
|||
|
|||
hmmIt's all OK but.
I have everything great. Programs are executing and so on(as I called them in file whatever'exe). BUT - the (whatever.exe)window doesn't close after executing external programs. a little help please? :$ hmm |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 21:06 |
| Modify a C program | ayoub | C Programming Language | 3 | 15-Mar-2004 12:34 |
| error during program | rjd72285 | C++ Forum | 0 | 11-Nov-2003 19:49 |
| one program access another? | dgoulston | C++ Forum | 1 | 07-Oct-2003 12:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The