Sunday, April 1, 2007

Install printer

On Error Resume Next

Dim objNetwork, objPrinter

Set objNetwork = CreateObject("Wscript.Network")

objPrinter=inputbox("Please type the name of the printer: ", "Install Printer", "\\PrinterServer\Printer001")

objNetwork.AddWindowsPrinterConnection objPrinter

'MsgBox err.number

If err.number=70 Then
msgbox "You are not authenticated to the print server. You need to run PrinterServerConnect", 16, "Printer Not Installed"
err.clear

ElseIf err.number=-2147023095 Then
msgbox "Print queue name is invalid: " & objPrinter, 16, "Printer Not Installed"
err.clear

ElseIf err.number=0 Then
msgbox "You can select the printer " & objPrinter & " from the print menu", 64, "Printer Installed"
err.clear

End If

set objNetwork=nothing
set oWshShell=nothing

Related Titles

 
visitors since March 26 2007
©2007