Solved

Print from DOS to Network Printer

Posted on 2010-09-01
10
879 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 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