Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing from a command window (SP1)

    How do you print from the command line? I want to use a batch file to print a small text file but cannot find the correct syntax. If I use the PRINT command with no parameters other than the file name, I get the error "Unable to initialize device PRN". Using the command "Print /d:"brother hl-5050" filename", I get the error "Unable to initialize device brother hl-5050". Brother hl-5050 is my default printer. All my printers are USB printers.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printing from a command window (SP1)

    If the file is in a format that the printer can process directly, you can use the COPY command to copy the file to the PRN device. Take a look at <post#=368545>post 368545</post#> and this thread for more info.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing from a command window (SP1)

    The file is a text file but that doesn't work. As I said in my first post, I get the error "Unable to initialize device PRN". All my printers are USB printers and there is no PRN device. Device Manager does not show any printers. See attached screenshot. It looks as if the command window does not recognize USB devices.

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing from a command window (SP1)


  5. #5
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing from a command window (SP1)

    I've had some success on USB printers with Printfile by Peter Lerup.

    But it still doesn't match the simplicity of NET USE LPT1 ... to a parallel-port printer!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing from a command window (SP1)

    I tried the NET USE command in the following batch file:
    <hr><font face="Comic Sans MS">@echo off
    dir>dirlist.txt
    net use lpt2 andrew15brother1 /yes
    copy dirlist.txt lpt2
    del dirlist.txt
    net use lpt2 /delete</font face=comic> <hr>
    It works except that for some reason it doesn't generate a form-feed. I have to go to the printer and press the continue button to eject the page.

  7. #7
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing from a command window (SP1)

    Andrew

    I have no idea what your "/YES" parameter does, unless you left off the PERSISTENT: bit! (usually abbreviated as /p:y). You don't need it anyway in your BATch file.

    Form Feeds never used to be generated when printing in DOS* - you either had to put an 0x0c FormFeed character at the end of your text, or send the 0x0c character to the printer after your text file. I used a binary editor to set up a file called FF which simply had this character as the only data, and did COPY FF PRN. All that just to save pressing a printer button!

    An easier BATch file could be

    @echo off
    net use lpt2 andrew15brother1
    dir > lpt2
    copy FF lpt2 > nul
    net use lpt2 /d

    Personally I always use LPT1 or PRN (same animal), but LPT2 is fine!

    John

    * unless you used the actual PRINT command, which did cause a Form Feed!

    PS sorry about heavy editing -- it's been a long time...
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  8. #8
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing from a command window (SP1)

    John,

    Thanks for the info. Sorry for the slow response but I've been away for a few days. I got the "/yes" parameter from the link Leif included in his post (http://www.winnetmag.com/Article/Art...674/39674.html). I'm not clear how you create a file with the FF character in it. I don't have a hex editor. Could you post or email me a copy? Thanks,

  9. #9
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing from a command window (SP1)

    Andrew

    If you have a 3 Mbps broadband connection, you'll hardly notice the time taken to download the file! I've called it FF.txt, but you can call it anything you like!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •