To just run the file, ShellExecute() and CreateProcess() are the best options.
How do you want to redirect the output to a file / run a shell command, this complicates the situation ...
Output redirection is a command line function, and so the command you want to run must be passed to cmd.exe (on NT / XP +) passing through /c , and your command as parameters (either ShellExecute or CreateProcess ).
cmd /c "ipconfig >c:\debug\blah.txt"
It is best to use CreateProcess() and create your own channels to talk to stdin and stdout of the program (all this cmd does internally)
source share