# Printing to USB printer in Windows2000

**URL:** <https://www.ruby-forum.com/t/printing-to-usb-printer-in-windows2000/71601>\
**Category:** Ruby\
**Created:** [October 10, 2006, 7:59am UTC](https://www.ruby-forum.com/t/printing-to-usb-printer-in-windows2000/71601 "2006-10-10T07:59:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norman\_Belssner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb9ed0/32.png) [@Norman\_Belssner](https://www.ruby-forum.com/u/Norman_Belssner)\
**Post date:** [October 10, 2006, 7:59am UTC](https://www.ruby-forum.com/t/printing-to-usb-printer-in-windows2000/71601/1 "2006-10-10T07:59:52Z")

</div>

I have been printing to a HP printer in windows2000 using  
$stdout = File.open(“LPT1”, “W”)  
print “Line 1 \n”

I can even control the HP deskjet using Ascii control codes. I just  
got a new printer that interfaces using a USB port and is USB001 on the  
system. Replacing LPT1 with USB001 does not work. Any ideas?

---

<div class="post-metadata">

**Author:** ![Norman\_Belssner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb9ed0/32.png) [@Norman\_Belssner](https://www.ruby-forum.com/u/Norman_Belssner)\
**Post date:** [October 11, 2006, 12:35am UTC](https://www.ruby-forum.com/t/printing-to-usb-printer-in-windows2000/71601/2 "2006-10-11T00:35:17Z")

</div>

Norman Belssner wrote:

> I have been printing to a HP printer in windows2000 using  
> $stdout = File.open(“LPT1”, “W”)  
> print “Line 1 \n”
> 
> I can even control the HP deskjet using Ascii control codes.

By Win2K, that’s probably a gruesome hack for backwards compatibility  
with DOS programs that translates that to the proper driver calls. It’s  
improbable that you’re actually talking to the printer directly.

> I just got a new printer that interfaces using a USB port and is USB001 on the system. Replacing LPT1 with USB001 does not work. Any ideas?

For the quick hacks, write stuff to a temp file and do system(“print  
path\to\file”). For the less hacky version, use the bindings to the  
Win32API, or use a GUI toolkit - those tend to feature print support.

David V.
