Solved

Printing from .bat file

Posted on 2010-09-14
12
564 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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