How to open (run) a . bat file by php?

Asked

Viewed 562 times

1

I have a.bat file whose function is to send a.pdf file to printer. In the same directory I have my.php file. I used the function exec('imprimir.bat'), and tried the same.bat file code only using the.bat file system:

system('cmd /c cd C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader AcroRd32.exe /t "D:\documento.pdf" "HP DeskJet 2130 series" "HP DeskJet 2130 series" "USB002"').

And I even tried to link Javascript:

<input type="button" value="imprimir" onclick="window.open('imprimir.bat')" />

But nothing worked! The page is in an eternal loading loop and does not execute the command. Someone could help me?

  • If you had a little more logic, would solve this easy easy, you already solved the problem? or want the answer yet?

  • I’m half a beginner yet @Cristianmota, if you can help me then please!

  • If you hear how to loop this Batch, loop it, waiting for the existence of a .txt. file when you want to print, do the PHP code to create the file. txt and when it exists, Batch delete it and then make your impression. is a gambearra, but I believe it works. preferably, Compile this Batch, leaving the prompt hidden, then play in the boot folder.

  • @Cristianmota Could you explain me better? Give me examples or something like?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.