Here’s the code. It’s very specific to our environment and problem. We’re not even using this anymore. Now local IT support at our locations just create their own printerExport files with PrintBrm.exe and deploy them with the Print Management tool or a PowerShell function. It’s hard to make sense of it without the documentation I wrote to go with it, but I’ve put the first couple paragraphs here.
The objective of AutoPrinter is to reduce printer management workload on Field Services without creating additional workload for Operations
AutoPrinter is a method for automatically installing printers on workstations based on the subnet. Printer export files are generated using the
PrintBrm utility on Windows 7. These files are placed on server shares within subdirectories corresponding to particular subnets. A computer startup
script is distributed to clients through domain group policy. The startup script checks to see if the computer’s subnet has changed, or if the printer
export files have changed. If the subnet has changed, all printers for that subnet are installed. If any new or updated files are located in the subnet
directory, those files are installed. Network and file information is stored in the registry, and other values are implemented to allow IT to remove
existing printers, force a reinstall, or disable the script and prevent any changes.
Windows 7 has a Print Management utility with the capability to export installed printers to a single printerExport file. This file contains all the
necessary driver binaries, port configuration and even driver-specific options such as whether or not the duplexer is installed. This file can then be
taken to another Windows 7 computer and imported. Several LAN Administrators started using this technique after it was demonstrated in the Tiger
Team training. It is also shown in one of the PowerShell training videos.
The AutoPrinter script takes this concept a step further by having computers automatically download and install printerExport files that are relevant
for their location.
Locations will be setup in and as repositories for the printerExport files. These locations will contain a “GLOBAL” directory and
The global directory will contain only printerExport files with drivers that should be installed to all computers, such as the Lexmark Universal driver.
The subnet directories will contain any printerExport files for printer configurations specific to that particular subnet. By splitting the binary drivers
from the configurations in this way, the storage requirements and network utilization is dramatically decreased. The printerExport files will be
generated by LAN Admins and the Sector Admins will be responsible for reviewing and copying the files to the correct location on the share.
Group Policy will be used to deploy the AutoPrinter script to domain computers as a startup script. Each time the computer boots, it will determine
which subnet it is connected to, map a drive to the repository, then download and install any new or updated printerExport files that apply to its
If a directory corresponding to the computer’s subnet is not found, no changes will be made except for setting registry values. No customer impact is
expected on implementation because the Sector Administrators will need to create these subnet directories before any actions are taken. This allows
Field Services to implement on their own schedule.
There are several registry values the AutoPrinter script looks for when it runs. LAN Administrators can customize the behavior of the AutoPrinter
script on a particular computer by modifying these values with the Set-DCMAAutoPrinter script. The “Clean” option will delete any existing printers
or ports, the “Force” option will reinstall all relevant printerExport files, and the “Disable” option allows the script to be turned off on a per-computer
The script will log its actions to the AutoPrinter_.log file in the C:\Windows\TEMP directory.
There are several use cases that were taken into consideration when designing this script.
No changes should be made to any computers at a site (subnet).
Do not create a directory for the subnet on the share. The script will see there is no directory and not install anything.
Only printer drivers should be installed to computers at a site.
Create a directory for the subnet, but leave it empty. The script will see the directory exists and install the files from the global directory.
Printers should be installed to all computers at a site.
Create a directory for the subnet, and place printerExport files within it. The script will install the global files and files within the subnet
User is having a problem with their printers and they all need to be reinstalled.
Set Force flag. The next time the script runs, it will force a reinstall of the driver files and printer files from the share. The flag is set back to 0
after the script runs.
Computer has several old printers and ports that need to be removed.
Set Clean flag and Force flag. The script will delete all existing TCP\IP printers, then force the reinstall of driver files and printer files from the
share. Both flags are set back to 0 after the script runs.
Computer is a special case where changes to printers should not be automatically made.
Set Disable flag. The script will see the flag is set and exit before making changes. The flag will remain set through reboots and group policy