Code: Select all
$cmd = '"C:\Program Files\My Progams\test.exe" --help';
$out = shell_exec($cmd);
echo "<pre>".htmlspecialchars($out)."</pre>";Code: Select all
Usage: test їoptions] InputFile
where <options> are
-h or --help
Print this helpCode: Select all
$cmd = '"C:\Program Files\My Progams\test.exe" "C:\Documents and Settings\jon\My Documents\file.txt"';
$out = shell_exec($cmd);
echo "<pre>".htmlspecialchars($out)."</pre>";Code: Select all
'C:\Program' is not recognized as an internal or external
command, operable program or batch file.Interestingly, when I paste this string into a DOS Window that is running CMD, it works just fine.
Can anyone tell me the solution to this problem? It seems to happen also with back-tick (which makes sense since both back-tick and shell_exec are the same). I haven't tried any of the other options like popen yet. Hoping someone has an idea.
BTW, I can make the names into 8.3 names (with the ugly ~n things), but that is AWFUL and hardly intuitive if I want the user to select the file from a directory browser.
Thanks in advance!
Jon Rosen