I have a printer on my serial port (com1:) and a file that i want to print.
I can print this file by using the following commands:
MODE LPT1: = COM2:
MODE COM2: 9600,N,8,1,P
COPY filetoprint.txt LPT1
But when i try this in a batchfile, i get the error "Kan het pad niet
vinden. - lpt1" (translated: could not find path: lpt1)
@ECHO ON
MODE LPT1: = COM2:
MODE COM2: 9600,N,8,1,P
COPY %1 LPT1
The error occurs on the last line. Im sure that %1 has the proper
filename (i also replaced it with the filename).
The operating system i use is Windows 98 SE.
Could someone help me / give me some pointers?
type file > com#
Try it.
COPY drive:\foldername\filetoprint.txt LPT1
Ed
In article <4051b659$0$65160$d525...@news.wanadoo.nl>, Eduard Witteveen
> I have a printer on my serial port (com1:) and a file that i want to print.
>
> I can print this file by using the following commands:
> MODE LPT1: = COM2:
> MODE COM2: 9600,N,8,1,P
> COPY filetoprint.txt LPT1
>
> The operating system i use is Windows 98 SE.
I can't test it either, but will either of these work?
Is your printer is on COM2 or COM1?
@ECHO ON
MODE LPT1: = COM2:
MODE COM2: 9600,N,8,1,P
COPY "%1" LPT1:
@ECHO ON
MODE COM2: 9600,N,8,1,P
COPY "%1" COM2:
When i type this same command on the commandline, it works
>
> @ECHO ON
> MODE COM2: 9600,N,8,1,P
> COPY "%1" COM2:
Batchfile: Path not found - COM1
Commandline: works (1 file copied)
Im starting this batchfile from my application. Could this be related to
the problems im facing?
Which application? Have you tried the batch files on their own, to test if
they work?
I did note that your batch files all use com2 but your error message states
com1... IIRC your initial msg stated your printer was on com1.
I tried the batchfile on it's own and it still gives me the same error
message. Can it have to do with the fact that copy and type are commands
defined in the command.com? :S
> I did note that your batch files all use com2 but your error message states
> com1... IIRC your initial msg stated your printer was on com1.
It is com1 on my computer, and com2 on the computer of the customer. I
messed up a little bit :D.
>> Which application? Have you tried the batch files on their own, to test if
>> they work?
> An Visual Basic 6 application, i start the batchfile by doing a api call
> to the winexe
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/winexec.asp)
>
> I tried the batchfile on it's own and it still gives me the same error
> message.
If it doesn't work on it's own...
> Can it have to do with the fact that copy and type are commands
> defined in the command.com? :S
winexec would shell to command.com I suspect, and it should work ok if it
works under dos.
I'm going to clutch at straws here coz I find the symptoms strange and
don't have a serial printer here to test it with.
1) Are you using a linux/unix box or odd application to create the batch
files, so the line ends are not CRLF but something else?
2) Are you using notepad to create the batch files, instead of something
which isn't saving in plain ascii text?
Which OS are you using it on?
> It is com1 on my computer, and com2 on the computer of the customer.
Ahh, ok.
>
> 1) Are you using a linux/unix box or odd application to create the batch
> files, so the line ends are not CRLF but something else?
nodepad has always worked for me, also i would see it in the output of
the batchfile, if this messed up. I retyped the complete batchfile in
notepad and in edit.
> 2) Are you using notepad to create the batch files, instead of something
> which isn't saving in plain ascii text?
...
> Which OS are you using it on?
Windows 98 Second Edition.
ps:
Maybe you can try yourselve:
MODE LPT1: = COM2:
MODE COM2: 9600,N,8,1,P
COPY c:\autoexec.bat LPT1:
in batchfile should give an error and when the 3 lines are entered on
the commandline they will not(it behaves the same without anything
connected to the com port).
>> Which OS are you using it on?
> Windows 98 Second Edition.
A batch file runs under command.com in Win9x/ME so it will always work the
same from the command line and batch file, barring environment variables
and doubled percent signs and some other oddities.
> Maybe you can try yourselve:
> MODE LPT1: = COM2:
> MODE COM2: 9600,N,8,1,P
> COPY c:\autoexec.bat LPT1:
> in batchfile should give an error and when the 3 lines are entered on
> the commandline they will not(it behaves the same without anything
> connected to the com port).
I cut and pasted those three lines into a.bat and executed it. These lines
are executed from the batch file, not the command prompt.
===[screen capture]===
Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.
C:\Download>a
C:\Download> MODE LPT1: = COM2:
Resident portion of MODE loaded
LPT1: rerouted to COM2:
C:\Download> MODE COM2: 9600,N,8,1,P
COM2: 9600,n,8,1,p
C:\Download> COPY c:\autoexec.bat LPT1:
1 file(s) copied
===[/screen capture]===
I can't explain your symptoms... Was the notepad you used in Win9x or NT?
If under NT, I wonder if the batch file was in Unicode format?
Look at it in a hex viewer, just to be sure.
So apperently the LPT1 cannot be found if your working directory is
different from c:\
Thank you very much for all your time!
> Place your a.bat in "Program Files" and try again :D. Aint that funny?
>
> So apperently the LPT1 cannot be found if your working directory is
> different from c:\
>
> Thank you very much for all your time!
You seem to have a work around, which is good, but it works for me.
Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.
C:\Program Files>a
Resident portion of MODE loaded
LPT1: rerouted to COM2:
COM2: 9600,n,8,1,p
1 file(s) copied
C:\Program Files>
Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.
C:\WINDOWS\Desktop>ver
Windows 98 [Version 4.10.2222]
C:\WINDOWS\Desktop>
In properties screen:
Microsoft Windows 98 Second Edition
4.10.2222 A
@echo off
dir %1 /-p /o:gn > "%temp%\Listing.txt"
start /w notepad "%temp%\Listing.txt"
exit
but it does not close the MS-DOS box.
Any help is much appreciated.
Sorry for the long post.
===============================
This article was previously published under Q272623
SUMMARY
This article explains how to add the print directory feature, and how
to enable printing of the directory listing from within Windows
Explorer.
MORE INFORMATION
To add the print directory feature to Windows Explorer, follow these
steps:
Open Notepad, and then copy and paste the following text into Notepad:
@echo off
dir %1 /-p /o:gn > "%temp%\Listing"
start /w notepad /p "%temp%\Listing"
del "%temp%\Listing"
exit
Save the file as Prin.bat in the Windows directory, and then close
Notepad.
Start Windows Explorer, click Tools, and then click Folder Options.
Click the File Types tab, and then click File Folder.
Click Edit, and then click New.
In the Action box, type Print Directory Listing.
In Application used to perform action, click Prin.bat, and then click
OK.
Click OK, click Apply, and then click OK.
Open Windows Explorer, right-click the folder that you would like to
print a directory listing of, and then click Print Directory Listing.
The information in this article applies to:
Microsoft Windows 98
Microsoft Windows 98 Second Edition
Microsoft Windows Millennium Edition
>I'm trying to make the batch file described in Q272623 below to print
>to a file instead of to printer. I edited it to read as follows:
>
>@echo off
>dir %1 /-p /o:gn > "%temp%\Listing.txt"
>start /w notepad "%temp%\Listing.txt"
>exit
>
>but it does not close the MS-DOS box.
>
>Any help is much appreciated.
>
>Sorry for the long post.
The /w instructs the shell to wait until the started program is finished,
so if you don't want to delete the temporary file (like the example)
simply omit this switch and the window should be closed imedeately.
HTH
--
Greetings
Matthias
It works!!
Thanks.
One last question. I've researched this before posting here and, I
believe, the /p switch is a pause. But what does the /-p switch do?
Can it be deleted from the above batch file?
Again, thanks. You've been most helpful.
--
http://www.vdare.com
You can set some dir switches to the environment variable dircmd.
To be shure the output is continuous you can override that possible
setting with /-p.
See dir /?
--
Greetings
Matthias