stryker
stryker

Reputation: 223

Triggering shell_exec method in php

The command inside shell_exec method will obviously work on command line. I tried this method on web server but it doesn't work. Is there any additional syntax on how to trigger this?

echo shell_exec("'C:\Program Files\Adobe\Reader 10.0\Reader>AcroRd32.exe' /t C:\Documents and Settings\cgcuser\My Documents\Downloads\Documents\sample.pdf \\myserver\myprinter");

Upvotes: 0

Views: 780

Answers (3)

na8ur
na8ur

Reputation: 27

I would go for a different approach wich works fine in Windows 10

$WshShell   = new COM("WScript.Shell");
$oExec      = $WshShell->Run("AcroRd32.exe /t my.pdf", 0, true);

Upvotes: 0

Alex Lynch
Alex Lynch

Reputation: 951

Looks like you need to escape your backslashes.

Also, your second argument looks like it needs to be enclosed as a String.

echo shell_exec("'C:\\Program Files\\Adobe\\Reader 10.0\\Reader>AcroRd32.exe' /t 'C:\\Documents and Settings\\cgcuser\\My Documents\\Downloads\\Documents\\sample.pdf' \\\\myserver\\myprinter");

Upvotes: 1

Yifu Yu
Yifu Yu

Reputation: 17

use \\ instead of \ , because you used " instead of ';

Upvotes: 0

Related Questions