Solved

Print to LPT1 via CMD (legacy application)

Posted on 2009-04-14
15
5,808 Views
Last Modified: 2013-11-21
I have an old application that's used through RDP (Windows Srv 2003).  The session is created from a PC with a Label Printer attached via LPT1.

The application runs the following batch file when trying to print a labelg:-

type c:\temp\labeldef.rpt > LPT1:
type c:\temp\myprint > LPT1:
exit

On the 2nd line when trying to access the file 'myprint' the following error comes up (and nothing prints).

'the process cannot access the file because it is being used by another process'

What process?  How do I narrow this down?

This process works fine on a Windows 2000 server, just trying to move onto 2003 for first time.  Also, I can send a test page back to the label print from the RDP session, so it's connected via the session.

Any ideas with this please?

Thanks


0
Comment
Question by:stevendunne
  • 5
  • 3
  • 3
  • +2
15 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24137316
Assuming that lpt1: is not the issue here (and it could be), maybe the application does not close the myprint file before it calls this batch process?  Can you amend this to try doing just

rem type c:\temp\labeldef.rpt > LPT1:
type c:\temp\myprint
pause
exit

so you can see if the file will show to the screen (in this case it may be accessing lpt1: that is the issue).  Not sure if the LPT1: port will map OK
through RDP anyway without using a share on the user PC and a NET USE anyway?

Is this for one user or multiple btw?
Steve
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24137344
It could be that the rpt file is taking too long?
I assume the 'myprint' is a simple line feed?  Which is probably needed for that printer.
So, you can fake a delay by using the attached (if you have networking hardware installed).

type c:\temp\labeldef.rpt > LPT1:
ping 127.0.0.1 -n 5 > nul
type c:\temp\myprint > LPT1:
exit

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24137690
Good point.  I had assumed it might be the .rpt file was setting the printer up and the myprint was the "variable" text to print.

Do you happen to know if LPT1: will actually map through RDP like this OK, I know you can map serial ports and printers but I didn't think it "appeared" as LPT1: to the server side - everything I have setup as networked so nothing to try on at the mo.

Steve
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 67

Expert Comment

by:sirbounty
ID: 24137716
Yeah, I was second-guessing myself on that as well.
Just tested here - I cannot access lpt1 from an rdp session in my environment ("LPT1: is not a recognized device.")
0
 

Author Comment

by:stevendunne
ID: 24137925
"so you can see if the file will show to the screen (in this case it may be accessing lpt1: that is the issue)"

I've done this, and the file contents does show on screen.  What does this suggeest?

"Not sure if the LPT1: port will map OK through RDP anyway without using a share on the user PC and a NET USE anyway?"

I'm able to print a test page from the RDP session, back to the printer attached to the local PC  (LPT1).
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24138015
Yes, but how are you printing to lpt1?  Via the print interface?
What is myprint?  please confirm...
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24138064
Start a cmd.exe prompt on the rdp session.

Type

echo Testing > lpt1:
echo (Press control and L) > lpt1:   (doing what it says of course nt typing).
Does it come out?

I suspect not.

I think you need to share the printer on the workstation and then connect it for the user with a net use lpt1: \\userpc\printername /persistent:no or get it connected through a print server box.

Steve
0
 

Author Comment

by:stevendunne
ID: 24138091
I will try the above.  The odd thing is, this process works fine on a Windows 2000 server.  I guess Win2003 has changed, and just says no!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24138165
Pretty sure there used to be a checkbox "LPT" mapping in RDP client but not there in the version I have now, just "printer mapping".

From another article:
"
2. on server side run TSCC.msc and navigate to RDP-TCP Properties => click
Client Settings tab

verify you have "Use connection settings from user settings" checked

verify check boxes for Printer mapping, LPT port mapping and COM port
mapping under section "Disable the following:" are NOT checked
"
0
 

Author Comment

by:stevendunne
ID: 24167812
Thanks for your help, but I managed to get this resolved with the following commands:-

copy c:\temp\labeldef.rpt LPT1

copy c:\temp\myprint LPT1

Shall I split the points, u happy with that?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24168108
Ahh thats probably because sending to LPT1: is different to LPT1, also some people use LPT1.DOS - I think one is handled as a file, the LPT1: as a device.  

Split them or close it, upto you.

Steve
0
 
LVL 8

Expert Comment

by:JT92677
ID: 24381679
Basically you are trying to connect LPT1 to a printer on the WIndows 2003 machine.

Step 1: Be sure you can print to the printer from Windows (no doubt you can)
Step 2: Share the printer with a simple name with no spaces, like "DOSPRINT"
Step 3: Find out your WIndows machine full computer name, e.g. Right click "My computer"
then Properties, then Computer name, then look at Full Computer name. Change it to something
short if it's long or has spaces, e.g. "mywin2003"

Now go to the CMD prompt in WIndows

Net View  mywin2003

You should see one of devices is "DOSPRINT"

The rest is easy

net use lpt1:  \\mywin2003\dosprint

What you've done is make lpt1: direct all it's output to the shared windows printer that works as
a shared printer (even though you're not really sharing it with anyone else).

As strange as this sounds, it works, and has the advantage of using Windows to spool jobs,
handle the details of printing things coming from DOS. You can even print to a USB printer
that DOS cannot print to directly.

Check the printer setting using:  net use

If you want to disconnect the LPT1, use    net use lpt1:  /delete
then   net use    again, to see if it's no longer connected.

hope this helps.

The key is to share the printer first, and attach the DOS box to the shared device.

This will keep LPT1 attached to the printer for as long as the Windows 2003 system is running, until either you reboot, or use the /delete switch on the net use command.


0
 

Accepted Solution

by:
ee_auto earned 0 total points
ID: 24941057
Question PAQ'd, 500 points refunded, and stored in the solution database.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On a regular basis I get questions about slow RDP performance, RDP connection problems, strange errors and even BSOD, remote computers freezing or restarting after initiation of a remote session. In a lot of this cases the quick solutions made b…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question