Printing Using ASP and WSH 
Author Message
 Printing Using ASP and WSH

Hello,

Running Window 2000 Server with IIS.
We want to print to a printer from an ASP page
using the following code:

    ' Create FileSystem Object and Windows Script Host Network Object

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

       ' Connect to Network Printer from Windows Script Host

       strPrinterPath = "\\XXXX\lab10_laser"

       strUsername="userid"
       strPassword = "password"
       strMessage = "xyz"

       objWSHNet.AddPrinterConnection "lpt1:", strPrinterPath, False,
strUsername, strPassword

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When the "AddPrinterConnection" method is executed we receive the following
error:

        Error Type:
WSHNetwork.AddPrinterConnection (0x80070520)
A specified logon session does not exist. It may already have been
terminated.
/fence/prbk.asp, line 51
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
We have tried various userid/passwords with same result.

Any help appreciated,
Gary



Wed, 15 Dec 2004 02:09:52 GMT  
 Printing Using ASP and WSH
I don't think you'll be able to do it this way. AFAIK this is
asynchronous (somebody confirm/deny?) - which means ASP will barf on it.

function String.prototype.r(){// Javascript rot13 en/decipherment. run
me for Atrax's signature
        var a='nopqrstuvwxyz';var b='abcdefghijklm';var j='/:.'+a+b;var
k='/:.'+b+a;var l='';
        for(var
x=0;x<this.length;x++){l+=k.charAt(j.indexOf(this.charAt(x)));}return l;

Quote:
}       alert("uggc://jjj.ernqgurshpxvatznahny.pb.hx/".r()); // Atrax, MVP

2002.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Wed, 15 Dec 2004 13:14:10 GMT  
 Printing Using ASP and WSH
:: I don't think you'll be able to do it this way. AFAIK this is
:: asynchronous (somebody confirm/deny?) - which means ASP will barf on
:: it.
::

Actually, it should work...  

It looks like code lifted right from this MSDN "Servin' It Up" column:

Using ASP and WSH to Print on Your Intranet
http://msdn.microsoft.com/library/en-us/dnserv/html/server033099.asp

I got the example in the column to work (sort of) by change LPT1 to LPT4 (LPT1 on my machine has a locally attached printer).  

I say 'sort of' because I also had to change the code to

  objPrinter.WriteLine(strMessage)

When I used to original

   objPrinter.Write(strMessage)

the text would usually be truncated if the last line in the textarea didn't actually have a CR+LF pair...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Thu, 16 Dec 2004 01:31:22 GMT  
 Printing Using ASP and WSH
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnserv/
html/server033099.asp

S. A. Hasnut
MCSD, CIW A
It Magnet
http://itmagnet.com.au

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Thu, 16 Dec 2004 05:30:42 GMT  
 Printing Using ASP and WSH
:: http://msdn.microsoft.com/library/default.asp?url=/library/en-
:: us/dnserv/ html/server033099.asp
::

How odd, I thought I had already posted that link over 4 hours ago...

Oh, it's Sarder - at least this time on topic ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Thu, 16 Dec 2004 05:44:02 GMT  
 Printing Using ASP and WSH

Quote:

> Hello,

> Running Window 2000 Server with IIS.
> We want to print to a printer from an ASP page
> using the following code:

>     ' Create FileSystem Object and Windows Script Host Network Object

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

>        ' Connect to Network Printer from Windows Script Host

>        strPrinterPath = "\\XXXX\lab10_laser"

>        strUsername="userid"
>        strPassword = "password"
>        strMessage = "xyz"

>        objWSHNet.AddPrinterConnection "lpt1:", strPrinterPath, False,
> strUsername, strPassword

> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> When the "AddPrinterConnection" method is executed we receive the following
> error:

>         Error Type:
> WSHNetwork.AddPrinterConnection (0x80070520)
> A specified logon session does not exist. It may already have been
> terminated.
> /fence/prbk.asp, line 51
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> We have tried various userid/passwords with same result.

> Any help appreciated,
> Gary

I too am having the same problem, someone please help.....


Sun, 09 Jan 2005 05:03:46 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Printing from ASP using WSH

2. Using ASP and WSH to Print on Your Intranet (Why doesn't it work)

3. Using ASP and WSH to Print on Your Intranet (Does not work)

4. Help with using ADO in WSH not ASP.

5. ASP and WSH sharing the same include using JScript

6. Using WSH in Asp

7. no results-call asp pg using WSH

8. How do you call an asp page using wsh

9. Can WSH be used in .asp docs?

10. Permission denied when retrieving environment variables using wsh from asp

11. Launching a Bat file from withing ASP using WSH

12. Executing a program from ASP using WSH

 

 
Powered by phpBB® Forum Software