Recipe 3.17. Printing to a USB Printer from DOS


Problem

You need to print from DOS or command-line programs but have a USB printer.

Solution

Using a graphical user interface

  1. Click Start, then select Printers and Faxes.

  2. Right-click the icon for your printer, then select Sharing.

  3. Select the Share This Printer radio button, then type in a name for the shared printer.

  4. Click OK to close the dialog, saving the results.

  5. Once the printer is shared it can be mapped to an LPT port assignment that DOS understands by following the next steps for using a command-line interface to complete this recipe.

Using a command-line interface

Use the following command:

> net use lpt1: \\localhost\<printername> /persistent:yes

where <printername> is the name you gave the printer share in step 3 above. Then run the following command:

> dir > lpt1:

This will print out a list of your current directory. When you need to print from a DOS program, make sure the program is set to use LPT1 so the printed output will go through the LPT1 port assignment to the newly shared USB printer.

Discussion

DOS is not aware of and does not support USB devices. To print from a DOS program using a USB printer you have to fool XP into thinking it's sharing a local printer and capture all print data sent to that local printer as if it had an LPT-attached device. The NET USE solution is a simple, eloquent workaround to bridge old technology to new.

See Also

HP has lots of information available at h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl11166.



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net