Solved

Printing from .bat file

Posted on 2010-09-14
12
537 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 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

10 Experts available now in Live!

Get 1:1 Help Now