Add a Network Printer via a script

The script below will allow end users to be able to add their own network printer via a automated script.

The script will also prompt the end user if they would like to make it the default printer and it will make this change for them.

On error resume next
Set WshNetwork = CreateObject("WScript.Network")

Dim PrinterName
Dim PrinterDriver
Dim strServer

'Change these for each printer
PrinterName = "Xerox4595"
PrinterDriver = "Xerox 4595 PS"
strServer = "\\YourPrinterLocation\"

StrApp = "Printer Status"


Sub Add_Printer

msgbox "This program will add the following printer: " & PrinterName & vbcrlf &_
"After choosing OK it may take about a minute for the printer driver to load.", vbokonly + 4096, "Add Printers"

PrinterPath = strServer & PrinterName
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
MsgBox "The following Network Printer has been added: " &_
vbCrLf & PrinterName,vbOKOnly + 4096, "Printer Status"

input =  msgbox ("Would you like to set " & PrinterName & " as your default Printer?", vbyesno + 4096, strApp)
'msgbox input 'for testing

 if input = "6" then
  printer = strServer & PrinterName
  WshNetwork.SetDefaultPrinter printer
  MsgBox "Your default printer has been successfully set to: " & PrinterName, _
     vbOKOnly + vbInformation + 4096, StrApp
 End if
 if input = "7" then
 end if
End sub


  • I really need help with this...I have the following script but it works in IE, Firefox but not Google Chrome. I can't figure out what I'm doing wrong..can you please help? Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection "\\PrintServer\Printername" - pesdaniel 3 years ago
This post is locked
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ