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"
Add_Printer
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
Wscript.quit
end if
End sub
objNetwork.AddWindowsPrinterConnection "\\PrintServer\Printername" - pesdaniel 7 years ago