As a linux administrator I always prefer CLI mode than GUI. But at work I also have to manage windows machines. Most boring task in windows is Printer Installation. If you don’t have active directory at your place you can’t automate the task & you have to go to user’s desk for installation. But windows have some in built script which can help you in installing printer from command line mode.
This script can be used to create / delete TCP/IP port for ip based printer.
This script can be used to install / uninstall drivers for particular printer.
this script can be used to install / uninstall printer.
Note : All above files are located at %windir%\system32\ Above files are not there in Windows Vista & Windows 7. You can copy above files from Windows XP machine and put them in %windir%\system32\
For example, I am adding HP LaserJet P2015 PCL 6 series IP based printer. Printer IP address is 192.168.1.10. All the drivers are stored in \\192.168.1.2\printer\2015\ folder
Below is the batch file to automate the task on client machine. Adjust below batch file as per your need & save it as bat file.
@echo off rem "Printer Automation" rem "Created by Vidyadhar" rem "Mapping the network drive" cd \ net use v: /DELETE net use v: \\192.168.1.2\printer\ rem "Creating TCP/IP port" cd \ cscript %windir%\system32\prnport.vbs -d -r IP_192.168.1.10 cscript %windir%\system32\prnport.vbs -a -r IP_192.168.1.10 -o raw -n 9100 -h 192.168.1.10 rem "Installing Printer's Driver" cscript %windir%\system32\prndrvr.vbs -a -m "HP LaserJet P2015 Series PCL 6" -h "V:\\2015\\" -i "V:\\2015\\hppcp604.inf" rem "Installing Printer" cscript %windir%\system32\prnmngr.vbs -a -p "HP_Printer" -m "HP LaserJet P2015 Series PCL 6" -r "IP_192.168.1.10" rem "Making it Default printer" cscript %windir%\system32\prnmngr.vbs -p "HP_Printer" -t rem "Deleting mapped drive" net use v: /DELETE
Feel free to comment.