Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 913
  • Last Modified:

Print from DOS to Network Printer

Is there a way to write a bat file to print to a network printer?
0
Fig68
Asked:
Fig68
  • 4
  • 3
  • 2
  • +1
2 Solutions
 
mikesussCommented:
0
 
mikesussCommented:
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
 
mikesussCommented:
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
Fig68Author Commented:
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
 
lewisgCommented:
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
 
mikesussCommented:
instead of \\share\printername use \\ip_address\name
0
 
lewisgCommented:
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
 
Basel-KCommented:
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
 
lewisgCommented:
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
 
Fig68Author Commented:
Thanks for the help
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now