Click to See Complete Forum and Search --> : VBScript: intranet printer install type mismatch error??


JBird80
April 10th, 2008, 12:33 PM
I'm not sure if this is the right forum but it’s a start. I've created a web page that shows where network printers are on a graphical map and when I click on a printer the printer will install. It works wonderfully when it was local but when I moved it to the server running IIS I get the error below.

Line: 1
Char: 1
Error: type mismatch error: 'Installprinter'
Code: 0
URL: printers.whatever.com

HTML Button Code


<input language="vbscript" type="button" value="install" onclick="vbscript:Call Installprinter ('\\printserv\printer1')">
VBScript


option explicit
on error resume next
Dim printer_name

Set WshNetwork = CreateObject("WScript.Network")

Sub Installprinter(printer_name)
WshNetwork.AddWindowsPrinterConnection printer_name
If MsgBox("Set "& printer_name & " as default?", 4, "Set default Printer") = 6 Then
WshNetwork.SetDefaultPrinter printer_name
Else
WScript.Quit
End If
End Sub


Any suggestions or leads on where to research next would be greatly appreciated.

PeejAvery
April 10th, 2008, 03:56 PM
This is the correct forum fo VBScript.

Concerning your problem...When you moved it to the server, are you attempting to execute if from the server, or is the client (browser) machine still executing the VBScript?

This will make a HUGE difference. The server itself won't be able to install onto the client machines. If the server is attempting it, then it will fail because the server is attempting to install a printer onto itself, not the client.

I hope I communicated my point.