Tip
Subject Content

234
Print to a USB printer from the command prompt

You typically print to a parallel-port printer by copying a file to

the lpt1: device. Because USB devices don't connect through an LPT

device, you can't take the same approach to print to a USB printer

from the command prompt. However, you have several options that will

work.



If a network adapter is connected to your network, you can share the

printer with another machine on the network and map the printer to

LPT2 or LPT3. For example,



net use LPT2 \\<machine>\<printer share> /yes



shares the printer on LPT2. By sharing the printer, you can copy files

from the command prompt to the printer on that port.



If you don't have a network adapter, you can install the Microsoft

loopback adapter, which emulates a network adapter, create a printer

share on your machine, then use the Net Use command to print to the

printer share.



Alternatively, if the USB printer is your machine's default printer,

you can use Microsoft Notepad to print an ASCII file to the printer.

For example,



start /min notepad /P <filename>



prints the file from Notepad to the printer, where "filename" is the

name of any file that you can open in Notepad that you want to print.

You don't have to include "start /min" for this technique to work, but

you'll want to include this command if you're printing from a batch

file to minimize the command window while the batch file runs.

Otherwise, the Notepad executable will steal focus away from the batch

file that issues this command and could stall the batch file after

printing is finished. To continue processing the batch file, you'd

need to click the command window.

.

Page 235 of 237
First Previous Next Last