[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Printing from .bat file

Posted on 2010-09-14
12
Medium Priority
?
583 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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