Copy a Print File to LPT1: 
Author Message
 Copy a Print File to LPT1:

Does anyone know how to copy a file to the lpt1: port.  I can do it from a
command line and from a batch file but haven't figured out how to accomplish
the same thing with a script.

I could perform the task with a batch file but it opens a window and leaves
the window open when it is finished.  If you know a way to get around that
it would be helpfull also.

Thanks in advance.

Bob



Sun, 04 Aug 2002 03:00:00 GMT  
 Copy a Print File to LPT1:
easy way:

Set Shell = CreateObject("Wscript.Shell")
Shell.Run "Notepad /p dsk:\dir\myFile.txt",0,True

or, for diehard DOS fans:

Set Shell = CreateObject("Wscript.Shell")
Shell.Run "%comspec% /c copy dsk:\dir\myFile.txt, prn",0

cheers, jw


Quote:
> Does anyone know how to copy a file to the lpt1: port.  I can do it from a
> command line and from a batch file but haven't figured out how to
accomplish
> the same thing with a script.

> I could perform the task with a batch file but it opens a window and
leaves
> the window open when it is finished.  If you know a way to get around that
> it would be helpfull also.

> Thanks in advance.

> Bob



Sun, 04 Aug 2002 03:00:00 GMT  
 Copy a Print File to LPT1:
The first approach is okay if you want the default header/footer and the
file is in fact a text file.  However, if it is a saved printer image
file, this approach is not appropriate.  (Note that the request does not
stipulate a text file.)

Further, if the file in question is a printer image the COPY command in
the second approach should probably be a binary copy (/B switch).

Plus, I tried addressing the printer port as a file and it worked for me
(VBScript syntax) ...

  Set ofs = WScript.CreateObject("Scripting.FileSystemObject")
  ofs.CopyFile "D:\Someplace\Somefile", "PRN", True

The printer must be ready and the file uses the printer's selected
internal font and paper tray, not those set by the Windows driver.  But
in some cases, this might be just the ticket.

In fact, this even works for me ...

  Set ofs = WScript.CreateObject("Scripting.FileSystemObject")
  Set oPrinter = ofs.OpenTextFile("LPT2", 2, True, 0)
  oPrinter.WriteLine "This is a test file"
  oPrinter.WriteLine "This is a second line"
  oPrinter.Write Chr(12)  ' Formfeed for most printers
  oPrinter.Close

(DOS port LPT2 is 'captured' to a network printer in my setup.)

I tried sending to a 'paused' printer driver that was attached to an
existing PRN port that does not have a printer attached on my machine
and was 'denied access'. (It works fine from a command prompt, just not
from the script).  But, sending to a network printer worked fine.  I
must assume it will also work to a local port that DOES have a printer
attached, but I can't say that first hand.

The answer to closing the window opened by a batch procedure is to leave
the console display EMPTY when the procedure is done.  That is, start

must also be Black - in case ANSI.SYS is in USE).  Also, using a zero
for the intWindowType parameter in the .Run hides the whole process, but
the 'hidden' console must still be empty to have the session close.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Quote:

> easy way:

> Set Shell = CreateObject("Wscript.Shell")
> Shell.Run "Notepad /p dsk:\dir\myFile.txt",0,True

> or, for diehard DOS fans:

> Set Shell = CreateObject("Wscript.Shell")
> Shell.Run "%comspec% /c copy dsk:\dir\myFile.txt, prn",0

> cheers, jw



> > Does anyone know how to copy a file to the lpt1: port.  I can do it from a
> > command line and from a batch file but haven't figured out how to
> > accomplish the same thing with a script.

> > I could perform the task with a batch file but it opens a window and
> > leaves the window open when it is finished.  If you know a way to get around
> > that it would be helpful also.

> > Thanks in advance.

> > Bob



Mon, 05 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. printing by copying to LPT1:?

2. copy .ps lpt1

3. copy lpt1 w/ WSH

4. copy to LPT1 via WSH

5. Endless copies printed from printing a single copy

6. Find a copy a file with File.Copy method

7. Copy multiple files and checking if all files are copied

8. Wanted: Redirect LPT1 to .PS file

9. printing copy count (xx of yy copies) on page

10. Printing multiple copies of a file

11. Print files to shared printer by copying them

12. Printing multiple copies of a PS file.

 

 
Powered by phpBB® Forum Software