Prompt if Cant Write to LPT1
Results 1 to 9 of 9

Thread: Prompt if Cant Write to LPT1

  1. #1
    Join Date
    Jun 2000
    Posts
    332

    Prompt if Cant Write to LPT1

    Hi,

    I wanna include this lines in the autoexec.bat file:

    @echo ff
    copy test.txt lpt1


    What this txt file does is to reconfigure the printer's setting. It will set the paper size to A4.

    Now, I got a problem here. The file updates the printer at boot time. But sometimes, the users do not turn on the printer. And then the error will be shown saying

    Write fault error writing device LPT1
    Abort, Retry, Ignore, Fail?

    How do I program in such a way that if the above error appears, another message also shows telling user to turn on the printer, if they have not done so. Something like this:

    Please turn on printing device.
    Write fault error writing device LPT1
    Abort, Retry, Ignore, Fail?

    Thanks!
    Last edited by topdome; March 11th, 2003 at 01:20 AM.
    EveryONe I daTe alw@ys turns out to be sUCh a cyborg.

  2. #2
    Join Date
    Jan 2000
    Location
    Pittsburgh, PA USA
    Posts
    2,053
    Hi There,
    Could you add the following lines above your copy command ?

    @ECHO OFF
    ECHO Please make sure the printer
    ECHO is turned on before you continue
    PAUSE
    copy test.txt lpt1

    Dave
    *** Help others less fortunate.

    JESUS IS LORD !

  3. #3
    Join Date
    Jun 2000
    Posts
    332
    hi davidgsmith,

    thanks for your suggestion. but i got one problem with that.
    most of the time the printer will be on. so, by adding those additional lines, the batch will pause every time, irregardless whether the printer is turned on or not.

    any other way?

    thanks!
    EveryONe I daTe alw@ys turns out to be sUCh a cyborg.

  4. #4
    Nix's Avatar
    Nix is offline Aka: Nix*, NNiixx, Nix23
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    8,255
    Wait a little longer and I'm sure one of the DOS gurus will supply the answer.

    Vernon most probably.

  5. #5
    Join Date
    Jan 2000
    Location
    Pittsburgh, PA USA
    Posts
    2,053
    Hey topdome,
    I was thinking about this, this afternoon
    Unfortunately I'm at the limits of my batting skills

    There should be some time of function that could be run at this time in the autoexec.bat to see if the printer is turned on.

    Don't know what if any, info about your printer or what type connection it has would be relevent to performing that function.

    The gentleman mentioned above, Vern, has a website site with many batch file links. You could start looking yourself for something that might work.

    http://www.comp-air.com/vfrazee/batch/index.htm

    Let us know,
    Dave
    *** Help others less fortunate.

    JESUS IS LORD !

  6. #6
    Join Date
    Jun 2001
    Location
    Jacksonville,Fl,USA
    Posts
    341
    Hi topdome, here's a group of batch utilities that I find almost indispensible, including one called PCHECK.COM that checks to see if a parrallel printer is present. Looks like what you're looking for.

    Dex

    EDIT: You want to download the file called horst32.zip.

    And, authors homepage has more good tools and info.

    Also, if you decide to use this, I would suggest this: Make the printer test as a separate batch file that you call at the end of the autoexec.bat. Call it something like PRNTTEST.BAT, or whatever you want. Then, add this line to the end of your autoexec.bat:

    PRNTTEST.BAT

    Then, use something like this for the actual batch file:

    :: prnttest.bat
    @echo off
    pcheck.com
    if not errorlevel goto Main
    cls
    echo.
    echo Please turn printer on before continuing!
    echo.
    pause
    :Main
    copy test.txt lpt1

    And obviously, either put PCHECK.COM in your C:\DOS or C:\WINDOWS\COMMAND directory, or include its full path in the batch file, ie.,

    C:\DOS\HORST\PCHECK.COM

    or where ever you put it.
    Last edited by Dexahol; March 12th, 2003 at 08:41 PM.

  7. #7
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    Here and example of one way to do it using nothing more than DOS:
    Code:
    @echo off
    echo [Alt-12]>~
    :PRNtest
    command/f/ccopy ~ prn|find "1 file(s) copied">nul
    if errorlevel 0 if not errorlevel 1 goto PRNready
    echo.
    echo Please make sure the printer is ready and then press [Enter] ...
    pause>nul
    goto PRNtest
    :PRNready
    del ~
    :End
    Notes:
    1. You'll need to replace that complete "[Alt-12]" string, (including the square-brackets), with the single form-feed character. Save the above as a text file then load it in EDIT. Delete the "[Alt-12]" string then, while holding down the [Alt] key, press the [1] then the [2] key on the numerical keypad, (not the keys at the top of the keyboard), then release the [Alt] key. The character you get should look like the one next to the "12" on this page: http://64.70.165.184/vfrazee/ascii.htm
    2. I'd probably add the above, (minus the "@echo off" line), to the C:\AUTOEXEC.BAT file.
    3. There is one small downside to using this approach. If the printer is not on when DOS processes these lines, as soon as you do turn it on, the printer will eject a piece of paper.
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

  8. #8
    Join Date
    Jun 2000
    Posts
    332
    thanks alot vernon!

    didnt noe tat DOS is capable of all these!!!

    cool !
    EveryONe I daTe alw@ys turns out to be sUCh a cyborg.

  9. #9
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    You're Welcome! Glad I was able to help.
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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