-1

Hi would use shell_exec for direct print a PDF file. My code is:

<?php
shell_exec( 'print /d:"EPSON MFC-J265W" c:\file.txt');
?>

When i try to run this code i receive this error:

Unable to initialize the device Epson

Jimmy
  • 119
  • 1
  • 2
  • 7
  • don't create multiple questions for each error message you get, but add the errors in comments in your current question. – Peon Oct 24 '12 at 12:52

2 Answers2

2

I'd bet you need to put it in quotes.

<?php
shell_exec( 'print /d:"EPSON MFC-J265W" c:\file.txt');
?>

Ultimately, you should test this on the command line to see what actually needs done.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
1

I've just found a workaround!

$updateCommand = "w32tm /config /syncfromflags:manual /manualpeerlist:\\\"".$timeServers."\\\" /update";

$updateCommandCmd = 'cmd /c " '.$updateCommand.' "';

$updateResult = shell_exec($updateCommandCmd);

using cmd /c and escaping both \ and " creating something like

cmd /c " w32tm /config /syncfromflags:manual /manualpeerlist:\"0.europe.pool.ntp.org 1.europe.pool.ntp.org\" /update " 

does the trick on windows 7 ONLY (sorry)

Matteo
  • 1,654
  • 17
  • 24