Installing printer driver failed, error code 0x2, HRESULT 0x80070057

Last week we had a print spooler problem on a XenApp 7.6/Server 2012R2 farm. The print spooler service grew to a whopping 16GB of Memory. The problem was related to a mix of old Ricoh and Kyocera drivers.
After upgrading to new drivers the problem of the spooler was resolved. But on one machine the Ricoh Universal Print driver could not be installed. We received the following error:

Installing printer driver – failed, error code 0x57, HRESULT 0x80070057. See the event user data for context information. Installing printer driver – failed, error code 0x57, HRESULT 0x80070057. See the event user data for context information.

Deleting all drivers from the printer server properties did not resolve the problem.
We also tried to fix it the old fashioned way, copying the folder “C:\Windows\System32\spool\drivers\x64\3” and the registry keys from a working server, but that worked neither.

So next is to check up the Driverstore for old installations.

– Open a command line window as an Administrator

– Run the command: pnputil -e. This command will list all the .inf files listed in the DriverStore, take note of all the .inf files where the manufacturer name is that of the printer affected. For sure the Class must be Printers.

For Example in this case:

Published name : oem40.inf
Driver package provider : Ricoh
Class : Printers
Driver date and version : 06/15/2015 4.7.0.0
Signer name : Microsoft Windows Hardware Compatibility Publisher 

Oem40.inf is the same as Oemsetup.inf of the Ricoh Universal Driver but renamed by the operating system.
Although all drivers are deleted from the print server properties, the Ricoh driver was still in the Driverstore repository.

Resolution in this case:

– Delete all the Rico inf files using the command: pnputil -f -d oemxx.inf, xx should be replaced by the value displayed by the pnputil –e command.

In this case: pnputil –f –d oem40.inf

After that, the installation of the driver was working as it should be.