lost in ASP & WSH!please help!

K

kyiu

I am using the VBScript and WSH to get the existing
printer network. The code:

<script language="VBScript" type="text/VBScript">
Dim existing
Set WshNetwork = CreateObject("WScript.Network")

Set objPrinters = WshNetwork.EnumPrinterConnections

For i = 0 to objPrinters.Count - 1 Step 2
MsgBox objPrinters.Item(i+1)
Next
</script>

The code works, however, I wanna show it on my asp
webpage, how can i get the VBS variable and then use
response.write to show "objPrinter.Item" ???

Please help!!Thanks a lot!!!
 
D

Dhananjay Modak

your code - slightly modified - works
<%
Dim WshNetwork, objPrinters, i
Set WshNetwork = server.CreateObject("WScript.Network")
Set objPrinters = WshNetwork.EnumPrinterConnections
For i = 0 to objPrinters.Count - 1 Step 2
response.write objPrinters.Item(i+1) & "<br/>"
Next
%>

If you dont see any printers the reason could be as follows:
Your web page might be running as anonymous (generally the user context
would be IUSR_<machine name>). If the printer connections are attached to
the logged in user profile then IUSR_... won't have any. Change the
security on the ASP page - remove anonymous and turn ON Integrated. It
should work now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top