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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top