Install and Add Network Printers from the command line

You can install network printers from the command line or with a batch file without the need of local admin access.  This way users can, for example, install a local network printer on their laptop when they are on a remote site.  This will work from Win 7 upwards to 10 and you don’t need to install anything. The scripts that are used are installed by default in C:\Windows\System32\Printing_Admin_Scripts.

There are 3 steps to take to install a printer. Try to use as many general drivers as possible to ease up the installation.

If you want to use PowerShell, then make sure you check out this post

Step 1 – Install the driver

cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "<Printer Driver Name>" -h "<Path to INF File>" -i "<"INF File>"

Look inside the INF file to get the correct driver name that is used.

Step 2 – Add the printer port

Cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnport.vbs" -a -r <Port Name> -h <Printer IP Address> -o raw

REM For example:
Cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnport.vbs" -a -r 192.168.20.200 -h 192.168.20.200 -o raw -n 9100

Step 3 – Add the printer

cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs" -a -p "<Printer Name>" -m "<Printer Driver Name from Step 1>" -r "<Printer Port Name from Step 2>"

REM For example
Cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs" -a -p "Canon_Test" -m "Canon PLC6 Class Driver" -r 192.168.20.1

 

5 thoughts on “Install and Add Network Printers from the command line”

  1. I’ve tried this method and while I initially loved how easy it was to script additional printers – it seems some computers require a restart for the script to work while others do not. I’m not sure why that is the case and have tried various different ways of running the commands and for some reason still come across it for the majority of computers.

    Did you also find this to be the case?

    • I only use the PowerShell version of the script lately. But what I can imagine is that maybe the print spooler service is blocking the installation. Have you tried restarting the spooler service first?

  2. How do you know which .inf file to use? We have like 8 files with .inf extension. Also, does the driver name have to match the name in the .inf file or can you just call it whatever name you want? If it needs to match where in the .inf file do you get the driver name? Thanks.

Leave a Comment

0 Shares
Tweet
Pin
Share
Share