Problem with AddPrinterConnection 
Author Message
 Problem with AddPrinterConnection

Hi,

I try to print a document on the server using ASP
this is the VBScript code i'm using;

objFS = CreateObject("Scripting.FileSystemObject")
Set objWSHNet = CreateObject("WScript.Network")

objWSHNet.AddPrinterConnection
"LPT1",<PrinterPath>,false,"<login>","<password>"
Set objPrinter = objFS.CreateTextFile("LPT1:", True)
objPrinter.Write("I want to print this text")
objPrinter.Close
objWSHNet.RemovePrinterConnection "LPT1:"
Set objWSHNet = Nothing
Set objFS = Nothing
Set objPrinter = Nothing

When i replace the tag <> with real info, i receive this error ;

WSHNetwork.AddPrinterConnection error '80070520'
A specified logon session does not exist. It may already have been
terminated

Anyone know why? I'm sure that the printer is correctly installed and use
the port lpt1 and i have admin access to the server.
I'm using Windows 2000 with sp1 and IIS 5. Any help would be greatly
appreciate.

Thanks



Mon, 01 Sep 2003 05:14:49 GMT  
 Problem with AddPrinterConnection
Try the AddWindowsPrinterConnection method instead...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


Quote:
> Hi,

> I try to print a document on the server using ASP
> this is the vbscript code i'm using;

> objFS = CreateObject("Scripting.FileSystemObject")
> Set objWSHNet = CreateObject("WScript.Network")

> objWSHNet.AddPrinterConnection
> "LPT1",<PrinterPath>,false,"<login>","<password>"
> Set objPrinter = objFS.CreateTextFile("LPT1:", True)
> objPrinter.Write("I want to print this text")
> objPrinter.Close
> objWSHNet.RemovePrinterConnection "LPT1:"
> Set objWSHNet = Nothing
> Set objFS = Nothing
> Set objPrinter = Nothing

> When i replace the tag <> with real info, i receive this error ;

> WSHNetwork.AddPrinterConnection error '80070520'
> A specified logon session does not exist. It may already have been
> terminated

> Anyone know why? I'm sure that the printer is correctly installed and use
> the port lpt1 and i have admin access to the server.
> I'm using Windows 2000 with sp1 and IIS 5. Any help would be greatly
> appreciate.

> Thanks



Mon, 01 Sep 2003 07:43:16 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. extend borland pascal to long filenames and use of win95/98/me/xp filedialogs

2. AddPrinterConnection Problem

3. addprinterconnection

4. DeletePrinterConnection, AddPrinterConnection

5. API AddPrinterConnection

6. Getting AddPrinterConnection Error

7. AddPrinterConnection fails: 1797: Unknown printer driver

8. AddPrinterConnection

9. Getting AddPrinterConnection Error

10. AddPrinterConnection in Win2000 Server

11. WSH 2.0 and the AddPrinterConnection ?

12. AddPrinterConnection

 

 
Powered by phpBB® Forum Software