Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP output to printer 1

Status
Not open for further replies.

laurapyl

MIS
Mar 11, 2004
5
NL
Users of our intranet make internal purchases with a "eshop". At the moment each order is created in the database and every now and then we look if there are new orders. First i wanted the system to send out an email, that will be an improvement. But the person who will receive the email is not always in. So now i think it is better to direct print the order (we need a hard-copy anyhow).
So i want my ASP print on a shared network printer. is this possible?
 
yes. i do that this way:

Code:
Dim strPrinterPath
Dim strMessage    
Dim objFS         
Dim objWSHNet     
Dim objPrinter    

strPrinterPath= "\\192.168.0.23\HP4000"

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objWSHNet = CreateObject("WScript.Network")
On Error Resume Next
objWSHNet.RemovePrinterConnection "LPT1:"

objWSHNet.AddPrinterConnection "LPT1", strPrinterPath, False, "", ""
Set objPrinter = objFS.CreateTextFile("LPT1:", True)

strMessage = "HELLO WORLD!" & chr(12)
objPrinter.Write(strMessage)
objPrinter.Close
objWSHNet.RemovePrinterConnection "LPT1:"
Set objWSHNet  = Nothing
Set objPrinter = Nothing

ttmug.gif
 
foxbox,
how would I use the script above to print to a printer connected to a Linksys print server.
Your help is greatly appreciated.
 
Change the printerpath in this line
Code:
strPrinterPath= "\\192.168.0.23\HP4000"

into the address of that Linksys (?) printer. Classic problem that you may encounter: user rights. Your webuser must be have rights to print on the printer.

ttmug.gif
 
BTW you can add userid and password to the AddPrinterConnection method:

Code:
objWSHNet.AddPrinterConnection "LPT1", strPrinterPath, False, "<userid>", "<password>"


ttmug.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top