【问题标题】:print with shell_exec on Windows 7在 Windows 7 上使用 shell_exec 打印
【发布时间】:2012-10-24 12:44:46
【问题描述】:

Hi 将使用 shell_exec 直接打印 PDF 文件。 我的代码是:

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

当我尝试运行此代码时,我收到此错误:

无法初始化爱普生设备

【问题讨论】:

  • 不要为收到的每条错误消息创建多个问题,而是在当前问题中添加 cmets 中的错误。

标签: php windows shell-exec


【解决方案1】:

我打赌你需要把它放在引号里。

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

最终,您应该在命令行上对此进行测试,看看实际需要做什么。

【讨论】:

    【解决方案2】:

    我刚刚找到了解决方法!

    $updateCommand = "w32tm /config /syncfromflags:manual /manualpeerlist:\\\"".$timeServers."\\\" /update";
    
    $updateCommandCmd = 'cmd /c " '.$updateCommand.' "';
    
    $updateResult = shell_exec($updateCommandCmd);
    

    使用 cmd /c 并转义 \ 和 " 创建类似的东西

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

    仅在 Windows 7 上有效(抱歉)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多