Group Policy Printer Preferences fails to set the default printer when new user profile is created


Symptoms


Using Group Policy Preferences to create a new printer mapping and set that printer as the default printer fails on Windows Vista and higher clients when the user is logging on for the first time.

The printer mapping is successfully created, but is not set as the default printer in the registry.  A printer preferences trace shows the following error:

<VALUE>The printer name is invalid.</VALUE></PROPERTY>-</INSTANCE>

Event ID 4098 is logged in the Application Log:

Log Name:      Application
Source:        Group Policy Printers
Date:          13/01/2009 4:07:48 PM
Event ID:      4098
Task Category: (2)
Level:         Warning
Keywords:      Classic
User:          SYSTEM
Computer:      server.fabrikam.com
Description:
The user 'HP Printer' preference item in the 'Define Printers {XXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}' Group Policy object did not apply because it failed with error code '0x80070709 The printer name is invalid.' This error was suppressed.

Cause


Group Policy Preferences creates the network printer mapping and calls the SetDefaultPrinterW() API before the user logon completes. At this point, the network connection under Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices is not created yet. So when it calls the SetDefaultPrinterW() API, it fails with the error code 0x80070709 "The printer name is invalid."

The printer connection registry values will only be created by the Spooler Service when it receives the SERVICE_CONTROL_SESSIONCHANGE notification. This notification message will only be sent AFTER the user logon completes. So when Group Policy Preferences calls SetDefaultPrinterW() the first time, the default printer will not be set.

Resolution


There is currently no hotfix available for this issue.

Possible work-arounds include:

  1. Force a group policy update after logon using the GPUPDATE /FORCE command
  2. Restart the Print Spooler (spooler) service after user logon
  3. Use a Scheduled Task to run a script after logon to define the default printer
  4. Use Registry Preferences to configure the default printer