Copy command to USB printer

Roller printer

If you need to send a dump of text to your printer for testing purposes, you can use this command:

> copy test.txt lpt1:

(assuming your printer is connected to that port).

What do you do when you want to use the copy command with a USB-connected printer? Open the printer properties, Ports tab — as you can see, the port name is usually USB001 or USB002.

If you change the command to:

> copy test.txt usb001

…a new file named usb001 will be created as a copy of test.txt. But we need to send the test.txt content to the printer, not copy it.

Here is what we do to get around this.

First step:

> net use lpt1: \\localhost\printername

(lpt1: becomes unusable for anything else after that, and the printer must be shared).

Second step:

> copy test.txt lpt1:

Try it — it does the job when you need a quick raw-text test print.

The modern alternative

On any currently supported Windows you have a cleaner option: Out-Printer in PowerShell, which sends raw text straight to any installed printer without touching port mappings:

Get-Content .\test.txt | Out-Printer -Name "USB001"

The LPT1-mapping trick above is still the tool for legacy 16-bit or DOS-era programs that insist on writing to a device port — but for ad-hoc test prints, reach for PowerShell first.

Leave a Reply

Your email address will not be published. Required fields are marked *