Solved

Print from DOS to Network Printer

Posted on 2010-09-01
10
902 Views
Last Modified: 2012-05-10
Is there a way to write a bat file to print to a network printer?
0
Comment
Question by:Fig68
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Expert Comment

by:mikesuss
ID: 33578745
0
 
LVL 4

Expert Comment

by:mikesuss
ID: 33578749
Use the net.exe command to establish a persistent connection. To do this, use the following syntax at a command prompt
net use lptx \\printserver\sharename /persistent:yes
where x is the number of the printer port that you want to map, where printserver is the print server that is sharing the printer, and where sharename is the name of the printer share.

For example, to map LPT2 to a printer shared as Laser1 on a print server that is named Pserver, follow these steps:
Click Start, and then click Run.
In the Open box, type cmd, and then click OK.
Type net use lpt2 \\pserver\laser1 /persistent:yes, and then press ENTER.
To quit the command prompt, type exit, and then press ENTER.
Note In Windows XP, non-administrative users cannot map an LPT port to a network printer path when the LPT port exists on the computer as a physical parallel port.

For more information about how to map LPT ports as a regular user, click the following article number to view the article in the Microsoft Knowledge Base:
313644  Non-administrators cannot remap an LPT port to a network printer
0
 
LVL 4

Assisted Solution

by:mikesuss
mikesuss earned 250 total points
ID: 33578757
313644  Non-administrators cannot remap an LPT port to a network printer
Back to the top
Method 2
Print directly to the printer share by using the following syntax at a command prompt
print /d:\\printserver\sharenamedrive:\path\filename
where printserver is the print server sharing the printer, where sharename is the name of the printer share, and where drive:, path, and filename make up the complete path of the document that you want to print.

For example, to print a document that is named letter.doc from the root directory of drive C to a printer shared as Laser1 on a print server that is named Pserver, follow these steps:
Click Start, and then click Run.
In the Open box, type cmd, and then click OK.
Type print /d:\\pserver\laser1 c:\letter.doc, and then press ENTER.

The following command-line message appears:
C:\letter.doc is currently being printed
To quit the command prompt, type exit, and then press ENTER.
Because Novell NetWare's CAPTURE command is not supported in Windows XP, use the following command to map the LPT port to a Novell NetWare print queue:
net use lptx \\server\queue
If the LPT port is redirected successfully, you receive the following message:
The command completed successfully.
To disconnect persistent LPTx connections, use the following syntax:
net use lptx /delete
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

Author Comment

by:Fig68
ID: 33579117
OK Cool I got it to test print to a shared printer with mikesuss method 2, one more question this printer isn't shared but does have an ip address is there any way of doing this with an ip address instead of a share name?

Thanks
0
 
LVL 7

Expert Comment

by:lewisg
ID: 33579185
I have used the methods in both of the comments above and while they work I feel a slicker solution is to use printer pooling.

Essentially all you do is open the properties page for the network printer you want to print to and go to the Ports tab. Click the "Enable printer pooling" check box and then check the box next to the LPT or COM port your DOS program prints to. After pressing the "Apply: button print jobs going to the LPT or COM port you specified will be handled by the network printer.

I have used this on quite a few networks, printers and applications. It seems to be reliable, more so than a batch file. It even works for printing in a Server 2003 remote session to a local printer.
0
 
LVL 4

Expert Comment

by:mikesuss
ID: 33579615
instead of \\share\printername use \\ip_address\name
0
 
LVL 7

Expert Comment

by:lewisg
ID: 33579726
Having used both methods for quite some time the printer pooling solution is easier, cleaner and less trouble. Unless you like writing batch files or the computer your trying to print from predates XP why bother?

An additional bonus is that if the printer is a stand alone network printer (not connected to a computer) the pooling solution can print directly to the printer eliminating network traffic and possible problems with the server computer.
0
 

Accepted Solution

by:
Basel-K earned 250 total points
ID: 33586918
you can Print directly to the printer share by using the following syntax
 
print /d:\\printserver\sharenamedrive:\path\filename
where printserver is the print server sharing the printer, where sharename is the name of the printer share, and where drive:, path, and filename make up the complete path of the document that you want to print.

to print a document that is named letter.doc from the root directory of drive C to a printer shared as Laser1 on a print server that is named Pserver, follow these steps:
Click Start, and then click Run.
In the Open box, type cmd, and then click OK.
Type print /d:\\pserver\laser1 c:\letter.doc, and then press ENTER.
0
 
LVL 7

Expert Comment

by:lewisg
ID: 33588247
Having come back to answering questions here on EE I'm now beginning to remember one of the reasons I stopped. Not to pick on anyone in particular but it seems that many don't read the entire message thread or if they do they have no problem in repeating previously given solutions. It is a bit frustrating to come back to a conversation and find the same ground being plowed again.
0
 

Author Closing Comment

by:Fig68
ID: 33931952
Thanks for the help
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

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…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…

734 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