Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Printing DOS file FileCopy LPT print spooler
;Print the same file to two seperate printers filetoprint = "C:\Temp\myfile.txt" printer1 = "\\ServerOne\Laser5" printer2 = "\\ServerTwo\Laser4" FileCopy(filetoprint,printer1,0) FileCopy(filetoprint,printer2,0)
From the DOS prompt create the file, put in a Form Feed (ASCII 12) and then end the file. Type:
copy con: Printme.txt rem The following is the Linefeed character ^L rem The following is the Formfeed/Page Eject Character (Alt+012) rem (Needed so that the printer will eject the page after printing) ^ZNow your WinBatch Commands will be:
FileCopy(filename, "LPT1", @false) FileCopy("printme.txt", "LPT1", @false) ;this file just has a form feed, to force the printer to print.
For example, in dos, if you copy a text file to the lpt1, it print it [If printer is hooked up and so on] . I was wondering if there is such a thing in windows.
For local printers...
FileCopy("xxx.txt","LPT1",0)For network printers
FileCopy("xxx.txt","\\server\printername",0)
Use w95AddPrinter or wntAddPrinter (the corresponding appropriate network extender functions) to map to LPT port.
If the Windows Capture of LPT1 will not work for you, but you can capture the port in DOS it successfully copies to LPT1, then you might want to hand this over to DOS via Winbatch, by invoking the DOS copy command to LPT1, specifically the 'capture' and 'send' commands.
PS -- 'capture' (and 'send /A=N') both required manually closing the DOS window when 'finished', so launching them via command.com (which has a command.PIF set up to "Close Window on Exit") will autoclose the DOS Window.
Ex:
RunHideWait("command.com", "/c send /A=N")Here's a more detailed example:
coms = Environment("COMSPEC") RunDOSCapture = Run(coms, "/c capture /q=.oper-01.mad /nt /nb /nff /ti=10 /l=1") message("RunDOSCapture", "returned %RunDOSCapture%") ;construct the full path-and-filename and pass to DOS copy FileStr1 = strcat(PortDrive,IdeeBatDir,"\import20.log") RunDOSCopy = run(coms, "/c copy %FileStr1% lpt1:")
CopyWorkedA1 = filecopy("AA", "lpt1", @false)will FAIL for the 1st such command [get "Error 1008: FileCopy Failed"].. then work ok for all [in my case, 2] subsequent such commands
[I put in a dummy 1st command -- i.e., printing a file I didnt really need, followed by the two 'real' ones.. then they printed.]
PS If @true is used as the third parameter ("warning",) then I get the "Confirm File Replace" window, asking whether I want to replace the file "lpt1" with "filename"..
I've had better luck copying to the print queue directly....
FileCopy("xxx.txt","\\server\prnter1",0)
We are getting this error in a test script until the large print job was over, and after that the function worked without error.
For example, the HP LaserJet 5/5M printer comes with the HP JetPrint utility. In Windows 95, the HP JetPrint is available for both networked and directly connected printers. HP JetPrint is represented as a tray icon in the lower right hand corner.
For the FileCopy to LPT to work, remove this icon from the systray. Do this by right clicking on the icon in the systray, and then reboot.
Now the FileCopy to LPT1 will work.
To reinstall the HP JetPrint icon, go into Control Panel/Printers, and right-click the HP LaserJet icon in Explorer, and select the menu item to install the icon into the systray. Then reboot.
tlogfile="test.txt" FileCopy(tlogfile,"LPT1",@FALSE) ExitI'm getting FileCopy Error 1008. What am I doing wrong?
I'm on a Windows 95 system attached to a Novell 3.12 network. LPT1 is attached to the fileserver (Compaq PageMark printer).
It turns out that if you execute the batch file from an extended filename directory, ie. "c:\Batch Files\" the filecopy will not work but if you rename the directory to a DOS 8 character name ie. "c:\BatchF\" it works fine. This problem exists in Netware only.
WinBatch basically passes both the source and destination to windows. It looks like Windows might pass it to the network driver and then that keels over.
Article ID: W13708
Filename: Using FileCopy to Print to a LPT Port or UNC.txt
File Created: 2001:03:15:10:19:30
Last Updated: 2001:03:15:10:19:30