Solved

Print from DOS to Network Printer

Posted on 2010-09-01
10
855 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now