Richard Knop Richard Knop - 7 months ago 75
PHP Question

Executing cmd commands in Windows from PHP Issue

Is it possible to execute cmd commands in Windows OS with PHP exec() function?

I tried this:


try {

echo exec(
'O:\test\pdftk.exe O:\test\outputs\OPP\out.pdf O:\test\outputs\OPP\out2.pdf cat output O:\test\123.pdf'

} catch (Exception $e) {
echo $e->getMessage();

Basically, I'm trying to merge two pdf files with the pdftk program. If I just write the same exact command to the cmd by hand, it works and the O:\test\123.pdf file is created. But when I execute the above PHP file, nothing happens (blank page, the file is not created).


Can your PHP user access cmd.exe? You might find the tools at Microsoft's Sysinternals very useful; particularly the process monitor.