Overview

Remote Desktop printing has long been a challenge in enterprise environments, particularly when dealing with multiple users accessing the same Terminal Server or Citrix XenApp environment. This article discusses a specific issue where printer registry entries persist incorrectly across user sessions, potentially leading to performance degradation and printing problems.

Environment Affected

Server Operating Systems:

  • Windows Server 2008
  • Windows Server 2008 R2

Remote Access Solutions:

  • Terminal Services (Remote Desktop Services)
  • Citrix XenApp 6.0
  • Similar solutions running on the affected operating systems

The Problem in Detail

When users connect to a Remote Desktop or Citrix XenApp session, the system automatically creates printer mappings to enable printing from remote applications to local printers. These mappings are stored in the Windows Registry under:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices

Under normal circumstances, these printer mappings should be removed when a user logs off. However, a bug in the affected systems causes these entries to persist incorrectly, leading to several issues:

  1. Registry bloat
  2. Slower printer enumeration
  3. Potential printing errors
  4. Increased session initialization time
  5. Resource consumption on the server

Technical Deep Dive

Let’s examine how this issue manifests in a real-world scenario:

Scenario Walkthrough

  1. Initial User Login (User A)

    • User A connects to XenApp/Terminal Services
    • System creates registry entries for User A’s printers
    • Entries are correctly stored in User A’s HKCU hive
  2. Second User Login (User B)

    • User B connects while User A is still active
    • System creates registry entries for User B’s printers
    • Critical Issue: The system inadvertently adds User B’s printer entries to all active user sessions, including User A’s registry
  3. User Logout Process

    • When User A logs out while User B is still active
    • User B’s printer entries remain in User A’s registry
    • These orphaned entries persist indefinitely
    • The next time User A logs in, they’ll have these invalid printer entries
  4. Cumulative Effect

    • Over time, users accumulate printer entries from other users
    • Each user’s registry becomes bloated with invalid printer references
    • Applications that enumerate printers (like our VB6 application) become progressively slower

Impact on Legacy Applications

In our environment, we discovered this issue through a custom VB6 application that relies on printer enumeration. The application exhibited the following symptoms:

  • Progressively slower printer list population
  • Increased memory usage when accessing printer information
  • Occasional application freezes during printer operations
  • Failed print jobs due to invalid printer references

Solution

Microsoft has acknowledged this issue and released a hotfix to address the problem:

  1. Apply the Hotfix

    • Download and install the patch from Microsoft Support (KB2620656)
    • The patch corrects the printer registry entry cleanup process
    • Ensures proper removal of printer mappings during user logoff
  2. Clean Up Existing Profiles

    • After installing the patch, existing user profiles still contain invalid entries
    • Recommended actions:
      • Delete existing user profiles
      • Allow profiles to be recreated on next login
      • Users will need to reconfigure their printer preferences

Best Practices for Prevention

To minimize printer-related issues in Remote Desktop environments:

  1. Regular Maintenance

    • Implement a profile management solution
    • Regularly clean up unused printer mappings
    • Monitor registry size for abnormal growth
  2. User Education

    • Encourage users to log off properly instead of disconnecting
    • Train users on proper printer mapping procedures
    • Document any specific printing workflows
  3. Monitoring

    • Track printer enumeration performance
    • Monitor user profile sizes
    • Watch for printing-related errors in event logs

Conclusion

While printer mapping issues might seem minor, they can significantly impact the performance and stability of Remote Desktop environments. The combination of the Microsoft hotfix and proper profile management should resolve this specific issue and prevent its recurrence.

For environments running legacy applications that heavily rely on printer enumeration, it’s particularly important to maintain clean printer mappings and regular profile maintenance to ensure optimal performance.