?
Solved

Printing from .bat file

Posted on 2010-09-14
12
Medium Priority
?
570 Views
Last Modified: 2012-05-10
Is there a way to print this from a .bat file?
print /d:\\servername\printername c:\test.txt

and also send this message to a computer on my network?
msg */server:pcname report is now printing

What I'm looking for is one .bat file that will print the txt file and send a message to a workstation alerting them of the printing.

Thanks
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
  • 4
  • 3
  • +1
12 Comments
 
LVL 7

Expert Comment

by:TechnoChat
ID: 33679169
For Printing you will get details here..
http://support.microsoft.com/kb/314499

For sending message..
net send name_of_user_or_computer the_text

Thanks
Saugata
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33679488
Hi, couldn't you just run a batch file that consisted of both lines:

print /d:\\servername\printername c:\test.txt
msg */server:pcname report is now printing

Or are you after some input parameters?

Rob.
0
 

Author Comment

by:Fig68
ID: 33681168
When I put this
"print /d:\\servername\printername c:\test.txt msg */server:pcname report is now printing"
in a bat file I get the message but the print command goes into a loop and doesnt print anything. How would you configure a bat file to print? If I put the command in cmd it prints just fine
No  input parameters just want this batch file to print.

Thanks for your help
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 25

Expert Comment

by:Lionel MM
ID: 33681461
I have never used the print command--I always use the copy file to lpt port script

Net use lpt1: \\servername\printsharename
Copy nameofile lpt1:
If ErrorLevel 1 goto error
GoTo Success

:Error
msg
Gotoi End

:Success
msg

:End
0
 
LVL 25

Expert Comment

by:Lionel MM
ID: 33681618
corrected

Net use lpt1: \\servername\printsharename
Copy nameofile lpt1:
If ErrorLevel 1 goto error
GoTo Success

:Error
msg
Goto End

:Success
msg

:End
0
 
LVL 7

Expert Comment

by:TechnoChat
ID: 33681855
If it is a text file, you can use following, very simple..

using notepad..

NOTEPAD /P c:\net.txt c:\test.txt
msg */server:pcname report is now printing

It will print on your default printer and send you the message..

Thanks
Saugata
0
 
LVL 7

Expert Comment

by:TechnoChat
ID: 33681858
Correct one..

NOTEPAD /P c:\net.txt
msg */server:pcname report is now printing
0
 

Author Comment

by:Fig68
ID: 33682124
Is there any way to make this print to a network printer instead of the default?

NOTEPAD /P c:\net.txt
msg */server:pcname report is now printing

Thanks
0
 
LVL 25

Expert Comment

by:Lionel MM
ID: 33682759
This can be any pc or server that has a printer shared
Net use lpt1: \\servername\printsharename
0
 

Author Comment

by:Fig68
ID: 33682891
"This can be any pc or server that has a printer shared
Net use lpt1: \\servername\printsharename"

But when I use "Net use lpt1: \\servername\printsharename c:\test.txt" it goes into a loop.

Sorry about this but I'm not that familiar with dos ;(
0
 
LVL 25

Accepted Solution

by:
Lionel MM earned 2000 total points
ID: 33683102
if you're at a DOS prompt its a two step process
first
Net use lpt1: \\servername\printsharename and enter
then
copy c:\test.txt" lpt1: and enter make sure to include the :

0
 

Author Closing Comment

by:Fig68
ID: 33684835
Thank you!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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