Introduction and Question
An application uses the Windows API call “enumprinters” to collect all shared printers within a user session on a terminal server. Sometimes some, or all, of the printers are missing in enumprinters, although they are visible in the devices and printers dialogue. This is what we call incorrect printer mapping.
To simplify this issue, the application was replaced by ShowPrinters.vbs, which can be found in the appendix.
Is there a possibility to ensure, that enumprinters always returns the correct and complete list of printers?
Setup of the machines
To recreate this issue, a minimum of three machines is proposed: A domain controller “DC”, a terminal server “TS” and a client “CLI”. All machines are virtual machines with access to 2 virtual processors, 2 GB RAM and a 20 GB hard drive.
To exclude any possible issues with the network connection, all machines should be connected to the same network. When using virtual machines, a host-only network can be used. All machines are configured to use the preferred DNS server at the DC.
Some printers, which are shared via network, are needed. To keep this setup simple, five printers are installed on the client.
Domain Controller “DC”
Windows 2012 R2 Standard Build 9600
- Step 1
- Install a Windows Server 2012 R2 Standard and install all mandatory updates
- Step 2
- Use “Server Manager” -> “Add Roles and Features” -> Installation Type “Role-based” -> choose the target “DC” -> Choose “AD DS” and “DNS”, each with standard settings -> install
- Promote to domain controller -> “Add a new forest” with root domain name “domain.com” and standard configuration
- Restart according to the installation process to finish the configuration for the domain
- Step 3
- Add a new user “testuser” and make the user member of “Domain Users” and “Remote Desktop Users”
- Step 4
- No actions required in this step
Terminal Server “TS”
Windows 2012 R2 Standard Build 9600
- Step 1
- Install a Windows Server 2012 R2 Standard and install all mandatory updates
- Step 2
- Add TS to the domain and restart
- Step 3
- Use “Server Manager” -> “Add Roles and Features” -> Installation Type “Remote Desktop Services” -> “Quick Start” -> “Session-based” -> choose the target “TS” -> standard settings
- Restart according to the installation process
- Step 4
- Navigate to “\CLI” to see the five shared printers and open each one to allow the driver to be installed
Client “CLI”
Windows 8.1 Enterprise Build 9600
- Step 1
- Install a Windows 8.1 Enterprise and install all mandatory updates
- Step 2
- Add CLI to the domain and restart
- Step 3
- Check, if “Remote Desktop Connection” to “ts.domain.com” with the “testuser” is operational.
- Step 4
- Add five test printers using the “Add a printer” dialogue: “The printer… isn’t listed” -> “Add a local printer” -> “Create a new port”, “Local Port” -> Port Name “c:\temp\1” through “c:\temp\5” -> print driver “Generic”, “Generic
/ Text Only” -> printer names “1” through “5” -> sharing activated with standard settings.In the local test environment other printer drivers likeHP universal driverare used with the same result.
- Add five test printers using the “Add a printer” dialogue: “The printer… isn’t listed” -> “Add a local printer” -> “Create a new port”, “Local Port” -> Port Name “c:\temp\1” through “c:\temp\5” -> print driver “Generic”, “Generic
/ Text Only” -> printer names “1” through “5” -> sharing activated with standard settings.In the local test environment other printer drivers likeHP universal driverare used with the same result.
Creating the incorrect printer mapping
- After finishing all setup steps above the shared printers are added to the GP:
- In Group Policy Management open “domain.com” -> “Default Domain Policy” -> “Edit”
- In “User Configuration” -> “Preferences” -> “Control Panel Settings” -> “Printers” right click and for each printer add “New” -> “Shared Printer” and enter the share path “\\CLI\1” through “\\CLI\5”
- On CLI start “Remote Desktop Connection”, make sure to not redirect the local printers into the session under “Local Resources” and connect to “ts.domain.com” with the “testuser”.
- As “testuser” on “ts.domain.com” create a shortcut to the ShowPrinters.vbs
- All printers should be installed and normal:
- Sign out.
- Log on “testuser” via RDP and as soon as the desktop is ready, open “Devices and Printers” and “ShowPrinters.vbs”, then sign out again. Repeat this for about ten times
- The ShowPrinters.vbs will now only show the “normal” printers and some will be missing: