0

I need to do a downloadable Windows batch file (.bat) which runs lpr command on clients machine. That's easy. The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser.

Is there any way to include .prn file (Print-to-file -file) in batch file? Or can I somehow include the printer data on lpr command?

Thanks!

besq
  • 155
  • 1
  • 2
  • 7
  • `lpr` doesn't sound like a Windows command. Which OS is running on the client's machine? – pavium Jun 13 '11 at 11:12
  • I'm using Windows 7, but any Windows should include this command. It's commandline (cmd) command. Sometimes (like in Win7) you have to activate it from control panel. – besq Jun 13 '11 at 11:25
  • Ah, I'm not familiar with Windows 7. `lpr` looks, to me, like a unix command, where there are a number of solutions. Oh well... – pavium Jun 13 '11 at 11:28

2 Answers2

0

As far as know you cannot include print data in your lpr command. You can specify the file to print and that is it. But do you know the printer name of all the clients? It sounds like there might be a better way of deploying if the clients are on the same network.

You cannot include a .prn file in a .bat (or .cmd) file in any reasonable way (even if the .prn file is a text file). Again if clients are on the same network the .bat file (or .cmd) could access the .prn file stored in a shared place.

steenhulthin
  • 4,553
  • 5
  • 33
  • 52
  • Yep, I know the printer name. Those have been identified by the user before the .bat file is generated in our web application. – besq Jun 15 '11 at 05:28
0

Lpr: Sends a file to a computer running Line Printer Daemon in preparation for printing.

Syntax

lpr [-S ServerID] -P PrinterName [-C BannerContent] [-J JobName] [{-o | -o l}] [-d] [-x] FileName

"The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser."

I'm a little unclear on this, however to me it sounds like you want the batch script to include the text of the data you wish to print?

It looks as if you can have the information in say a .txt file and pass it through lpr:

lpr -P printername -x file.txt

If you need information from a .prn file inside of this printed .txt file, you can try:

TYPE file.prn>>file.txt

However not sure if TYPE will work on a .prn file.

Anthony Miller
  • 15,101
  • 28
  • 69
  • 98