How can I print to a USB printer from the command prompt?

A. 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 will 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 complete. To continue processing the batch file, you'd need to click the command window.

If none of the above techniques are suitable for your particular situation, check out the Dosprn shareware utility available at Dosprn lets you print to any printer from the command line.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.