We start out by opening notepad or any other txt file editor, on the first line we want to put in the following without the brackets,
(on error resume next)
this tells the program when you encounter an error just continue at the next line. The next line we use theSet objNetwork = CreateObject("WScript.Network")
WScript.Network is a scripting object that provides methods and properties that allow for manipulation of network objects.
The next line you add in the printer
objNetwork.AddWindowsPrinterConnection "\\Server\Printer Shared Name"
after it has added the printer you will need to set it as the Default printer if you have more than one printer installed
objNetwork.SetDefaultPrinter "\\Server\Printer Shared Name"
So your finished script will look like this.
on error resume next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\Server\Printer Shared Name"
objNetwork.SetDefaultPrinter "\\Server\Printer Shared Name"
Save this with the file extension of *.vbs for example addprinter.vbs and then you can use it as a script in the logon process with a group policy, or if you simply double click on the file it will install the printer for you, if you are deploying this with group policy you will want to remove it after successful installation as it will not work the second time around, unless you change some of the parameters, as it will already be installed it will give you an error, the change to the script that is required is below
'objNetwork.RemovePrinterConnection "\\Server\Printer Shared Name"
This goes above the objNetwork.AddWindowsPrinterConnection "\\Server\Printer Shared Name" line in the script so your script will now look like this below.on error resume next
Set objNetwork = CreateObject("WScript.Network")
'objNetwork.RemovePrinterConnection "\\Server\Printer Shared Name"
objNetwork.AddWindowsPrinterConnection "\\Server\Printer Shared Name"
objNetwork.SetDefaultPrinter "\\Server\Printer Shared Name"