Install Printers via Script

Created by Chris Sandu, Modified on Thu, 27 Feb, 2025 at 4:29 PM by Chris Sandu


MIS Department Policy & Procedure 


Document Name:

Install printers via script

Document Type:

Procedure

Written by:


Date/Revision Date:




To remotely install a printer to a computer - will install to all profiles on the computer as well as the Default User Profile.

Browse to G:\Install\mistools\Printer Updates.  There are two folders:  DPTags (where scripts have already been created and saved by tag number) and Templates (has each depts standard printers).

 

If there is already a script there for a tag number, edit that batch file in Notepad, adding or removing printers as necessary.  Save it, and you can run that batch file from a command prompt from your computer or from the user's computer.  If there isn't look in the Templates folder and copy the template you need to a new Notepad window, edit for the appropriate dptag number (and printers if necessary), then save it to DPTAGS with the tag number.bat.

 

To execute the script, open a command prompt, go to the folder where the script is stored, and type in the batch file name.  The printers are installed on the remote computer, and the print spooler is stopped and restarted.  The new printer(s) will show up on the user's pc.  It can take a minute or two for the printers to show in Printers. 

 

Start button, Run, cmd

cd g:\install\mistools\printer updates\dptags

type in the batch file name

Close the command prompt box


Note:  Some Windows 7 pc's may not allow you to run the script from your computer.  To solve, run the script from the user's computer instead.



TECHNICAL NOTES (Behind the scenes details):

If need to install just one printer on one machine, can use cmd script.  addremoteprint.cmd is located in g:\install\mistools\printer updates\.  To use this script, at a command prompt:

addremoteprint DP#### server\printer

ie:  addremoteprint DP0862 seinfeld\label-DPS

This will add the dps label printer to computer DP0862 in all user profiles

If need to install a printer on multiple computers it may be easier to create a batch file with the specific printui command and parameters. Sample templates are in the Templates folder.  Script runs a printui command: 

          rundll32 printui.dll,PrintUIEntry /ga /c\\DP#### /n\\Server\PrinterName

/ga is globally add

/gd is globally delete

/c\\ specifies the computer to install to.  Use the DP tag number or computer name

/n\\ specifies the network server then printer name of the the printer to be installed

print spooler is stopped and started, then printer will show on remote computer

Create a batch file with the printui command, stop spooler and start spooler commands.  Example, to install the dps label printer to computers DP0862, DP0863, and DP0864, create a batch file as follows:

 

rundll32 printui.dll,PrintUIEntry /ga /c\\DP0862 /n\\Colpotter\PUBLABEL1 

start /wait sc \\DP0862 stop spooler 

start /wait sc \\DP0862 start spooler

rundll32 printui.dll,PrintUIEntry /ga /c\\DP0863 /n\\Colpotter\PUBLABEL1 

start /wait sc \\DP0863 stop spooler 

start /wait sc \\DP0863 start spooler

rundll32 printui.dll,PrintUIEntry /ga /c\\DP0864 /n\\Colpotter\PUBLABEL1 

start /wait sc \\DP0864 stop spooler 

start /wait sc \\DP0864 start spooler

 

The difference between the two are in the addremoteprint.cmd method, you are issuing one command with a specific computer and printer from the command line.  The script itself doesn't change.  The batch file method is easier when you have multiple computers or printers to install as you can copy and paste the basic info into the batch file and just change the computer numbers or printers as necessary, then run that batch file from the command line.  Both methods accomplish the same task.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article