• Printing from a command window (SP1)

    Author
    Topic
    #408511

    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.

    Viewing 3 reply threads
    Author
    Replies
    • #863047

      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 and this thread for more info.

    • #863048

      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 and this thread for more info.

    • #863505

      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

      • #863535

        I tried the NET USE command in the following batch file:
        [indent]


        @echo off
        dir>dirlist.txt
        net use lpt2 andrew15brother1 /yes
        copy dirlist.txt lpt2
        del dirlist.txt
        net use lpt2 /delete


        [/indent]
        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.

        • #863537

          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…

          • #864974

            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/ArticleID/39674/39674.html%5B/url%5D). 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,

            • #865038

              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

            • #865039

              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

          • #864975

            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/ArticleID/39674/39674.html%5B/url%5D). 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,

        • #863538

          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…

      • #863536

        I tried the NET USE command in the following batch file:
        [indent]


        @echo off
        dir>dirlist.txt
        net use lpt2 andrew15brother1 /yes
        copy dirlist.txt lpt2
        del dirlist.txt
        net use lpt2 /delete


        [/indent]
        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.

    • #863506

      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

    Viewing 3 reply threads
    Reply To: Printing from a command window (SP1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: