Need a little bit of help with C

DaiShan

Diamond Member
Jul 5, 2001
9,617
1
0
Hi guys, I've only recently started working with C, but I'm trying to create a program that will call several other programs, one at a time and wait for them to close before running the next program (the programs close on completion based on command line arguments passed to them), and I'm not having much luck. Can anyone point me in the right direction? Thank in advance.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
system() will probably do what you want, but calling external program is generally a bad idea because it's an exploit waiting to happen.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Don't use the "system" call if you want your program to run reliably. CreateProcess() is the preferred way of doing this on Windows.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Yeah, use CreateProcess. I don't think this is inherently a security weakness. Depends on how you do it and in what context. If I can substitute a different version of the process then I could do bad things, but that's no different than modding a DLL that a program loads. Heck, you can inject DLLs into a process address space at runtime.

The key to all these scenarios is access and context. You can't prevent your program from loading and executing external code in Windows (I'm not sure you can do it even with a simple console app). The key is to protect the integrity of the file system.