Solved

Printing from .bat file

Posted on 2010-09-14
12
529 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
  • 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
 
LVL 24

Expert Comment

by:lionelmm
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 24

Expert Comment

by:lionelmm
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 24

Expert Comment

by:lionelmm
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 24

Accepted Solution

by:
lionelmm earned 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
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…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

19 Experts available now in Live!

Get 1:1 Help Now