The execl
function call does not split the arguments for you. This basically means that you need to separate each command line argument as a different string parameter when invoking the function. For example:
execl("C::\\WINDOWS\\SYSTEM32\\CMD.EXE", "cmd.exe", "/c",
"echo", "foo", ">C:\\Users\\Sarp\\Desktop\\foo.txt")
However, I'm under the impression that the output redirection may not work (depending on how the Windows shell interprets those), so I encourage you to try the system()
function which resembles your usage case more closely.