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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web based printer install 1

Status
Not open for further replies.

gumbald

Technical User
Apr 6, 2006
16
I am trying to create a web based interface in order that users can choose a printer and it can be installed. This is to be implemented in a school with many, many printers. However, I have the function:

<script language="VBScript" type="text/vbscript">
<!--'
Sub MapPrinter()
Dim netPrinter, UNCpath
UNCpath = "\\casper\HPLaserJet4"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath
'-->
</script>

This produces the following when the page is accessed:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'MapPrinter'
/Printers/index.asp, line 25

Any thoughts?

Jamie
 
Where is the End Sub ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Don't know why it's not there, but I'm getting the same error when it is in. Is it because it is trying to install the printer on the server it is being run on?

Can anybody point me on the direction of the printer being installed to the computer the site is being accessed from?

TIA,
Jamie
 
Post more script lines. How is it called?
 
I am calling it simply by using

<%MapPrinter()%>

Apologies if I'm missing something really obvious, I only learnt VBScript last week, I'm now trying to translate to ASP and falling at the first hurdle!
 
Surely incorrect. One possible call would be.
[tt] <body onload="MapPrinter">[/tt]
 
It didn't throw up an error :) But it's not creating a printer...
 
Due you have On Error Resume Next in the script?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I do now, put it ahead of the Sub. Made no difference with the code as it is.
 
What code? Why waste members' time for not posting sufficient lines?
 
As I posted above, with the single line modification that was suggested. Apologies if that wasn't clear enough.
 
[tt]
<html>
<head>
<script language="VBScript" type="text/vbscript">
<!--'
Sub MapPrinter
Dim netPrinter, UNCpath
UNCpath = "\\casper\HPLaserJet4"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath
end sub
'-->
</script>
</head>
<body onload="MapPrinter"></body>
</html>
[/tt]
 
That's doing nothing either, although still no errors. How can I call another procedure to print some text just to check that the ASP is working properly on my IIS?
 
<html>
<head>
<script language="VBScript" type="text/vbscript">
<!--'
Sub MapPrinter
Dim netPrinter, UNCpath
MsgBox "Look at me! The function executed!"
UNCpath = "\\casper\HPLaserJet4"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath
end sub
'-->
</script>
</head>
<body onload="MapPrinter"></body>
</html>

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
If not even a prompt appears, it proves you have to change internet/intranet security zone setting on "Initialize and script ActiveX marked as unsafe" to "prompt" as a compromise concessing partial security measure or you have to look into hta for intranet with fully trustable admin.
 
It shows the message box, but bottom left it indicates an error still (next to Done):

"ActiveX component can't create object: 'WScript.Network'"

I am running Windows XP, so I have the latest WSH?
 
Remember that you want the printer to map on the user's computer and not the server.

For the purposes of mapping the printer, just ignore everything inside the ASP script delimitter tags: [highlight]<% %>[/highlight]

In fact, those guys above have the right idea... for testign purposes just make a plain HTML page with no ASP in it... then if you need ASP for server-side logic you can integrate the two after this bit of client-side code is working.
 
I've copied EBGreen's code exactly and now saved it as a .htm rather than .asp, but still gives the ActiveX error.

It was causing much confusion in the office, none of us have any such experience, so wondered where the client and server runtimes were. I have allowed "Active content to run in files..." in IE, but don't particularly want to have to do this across the whole site. Another option suggested was to have them download a vbs file and simply run it themselves, however the boss said it must be stealth, users can't be trusted with anything...
 
But your security settings prevent stealth changes?
 
I didn't know if it was them not allowing the ActiveX to run properly, that's the only thing I can think of. I've just re-read my post, it was a rather long-winded way of saying I just want one click to install a printer from a site :)

Can anybody shed light on the ActiveX error?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top