Installing printer with a single script.

I’ll keep it short this time.

Task: Deploy network printer drivers along with the install script to a number of machines.
New local TCP/IP port is required for the printer (if exists – delete and re-create), then copy drivers and install printer.

The batch script bellow will use the set of “Printing Admin Scripts” that you can find on each Windows 7 Pro/Ent/Ultimate as well as Windows 8.1 and Windows 10 under C:\Windows\System32

Now, our printer IP is:
Printer name is: Xerox WorkCentre 7435
Location: Office

Remember the varDriver has to be the actual driver name (ie.¬†TOSHIBA Universal Printer 2 or Xerox WorkCentre 7435 as in this particular example). If it won’t match the driver name from the .inf file, you’ll get “error 87 – unable to add printer” and the script won’t work.

you can set varDriverFolder and varDriverFile as network share as well as local hard drive location.

For Altiris users:

Create detection rule as “Registry Key Value” and point it to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Xerox WorkCentre 7435 with the registry entryPortand registry valueIP_192.168.1.100”¬†

You can also use the script below to add server shared printer and set it as default (it won’t set it for all users though)

@Echp off
SET serverhostname=SERVER
SET sharedprinterName=PRINTER
REM Adding printer
CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -ac -p “\\%serverhostname%\%sharedprinterName%”
REM Stopping the Print Spooler Service
net stop spooler
REM Starting the Print Spooler Service
net start spooler
REM Making it Default printer
CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -t -p “\\%serverhostname%\%sharedprinterName%”[/code]