douzuanze0486 2016-05-16 09:46
浏览 71

使用PHP执行bat文件在端口上打印

I would like to print a generated text (in ZPL) with a bat file in PHP on port LPT1. when I execute the bat file, its works normally but when I try to execute it with PHP nothing happen

in PHP :

system("cmd /c C:test.bat");

in bat file : copy C:\wamp64\www\labstock\print\eti.txt LPT1 PAUSE

Result with PHP :

C:\wamp64\www\labstock>copy C:\wamp64\www\labstock\print\eti.txt LPT1 0 fichier(s) copi�(s).

Result when I execute myself :

C:\wamp64\www\labstock>copy C:\wamp64\www\labstock\print\eti.txt LPT1 1 fichier(s) copi�(s).
  • 写回答

1条回答 默认 最新

  • dongxun6690 2016-05-16 11:34
    关注

    I had to share my printer and put the path in the bat file:

    1. Share the printer and give it a name

    2.in the bat file ( test.bat ) :

    copy eti.txt "\\PC_NAME\PRINTER_NAME"

    in PHP

    exec('cmd /c C:[PATH]test.bat');
    

    Or to get output :

    system('cmd /c C:[PATH]\test.bat');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于Lammps建模的描述
  • ¥15 #lingo#请问一下为什么会出现以下情况,是因为l第一个值是0的缘故吗?
  • ¥15 设计格雷码同步八进制计数器
  • ¥100 改写matlab程序(关键词-系统对)
  • ¥15 函数信号发生器仿真电路
  • ¥15 Qt的pixmap和image图片加载都导致程序崩溃怎么办
  • ¥15 Kali木马生成问题求解
  • ¥30 求一下解题思路,完全不懂
  • ¥15 C51单片机串口控制JQ6500语音模块
  • ¥30 想给yolo5模型加一个图片识别界面,但是图片还没有检测出来就闪退了