to lancelot:
it's simple exec($my_cmd) on windows executes 'cmd /c $my_cmd'
if there are any spaces in $my_cmd you have to put it in doublequotes:
cmd /c "$app $target" will work
further if there are any spaces in $app and $target they also have to be in doublequotes:
cmd /c ""$app" "$target""
therefore enclose your $cmd in two more doublequotes and dont forget to escape slashes \\
$cmd = "\"\"C:\\my path with spaces\\targetapp.exe\" \"C:\\mypathnospaces\\targetfile.xxx\"\"";
and exec($cmd) will work :)
no chdir anymore...