Category Archives: Printer

The simple way how to automate printer settings

The Problem

Printer settings are saved per user in the registry under the following key names: “HKEY_CURRENT_USER\Printers\DevModePerUser” and “HKEY_CURRENT_USER\Printers\DevModes2”. Best practice to be enterprise aware is to redirect those settings in a per machine (for all users) location. The settings will then be the same for every user. Deploying settings per user often needs much more effort to ensure that the settings are present to each user than deploying it per machine.

The Solution

Use the build in system api call in PRINTUI.DLL to export the needed printer settings. As result there will be a configuration file that can be used for automation purposes like command line or Custom Action in a Windows Installer based setup file and the printer settings will be automatically per machine based.

First the Printer settings must be set on a clean machine, for example:
PrinterSettings

Then the settings can be exported by using the following command line:
“C:\Windows\System32\rundll32.exe” PRINTUI.DLL,PrintUIEntry /Ss /n “PrinterName” /a “C:\SettingsFile.dat” /q g d r

The value “PrinterName” is the name of the printer you want to save the settings.
The value “C:\SettingsFile.dat” is the location and files where the printer details will be stored.

To import the settings on a client run the following command line:
“C:\Windows\System32\rundll32.exe” PRINTUI.DLL,PrintUIEntry /Sr /n “PrinterName” /a “C:\SettingsFile.dat” /q g d r

This command line can be used as example as a Windows Installer custom action:

Add the file “SettingsFile.dat” to the installation and create a new custom action at the end of “Execute deferred”:
printersettings