How to Remove Invalid Redirected Printers in RDP Sessions


In Remote Desktop Protocol (RDP) sessions, there is a common issue that users may face with invalid redirected printers. These printers may show up in certain applications, specifically some legacy systems. The core of this problem lies in the way the Print Spooler handles the registry entries associated with these printers. Over time, this can lead to the accumulation of invalid registry entries, causing confusion and operational issues. This article explores the nature of the problem and provides guidance on how to address it.


Remote Desktop Protocol (RDP) sessions are used to remotely access and control computers. However, some applications in an RDP session may present users with invalid printers. This occurs due to the way the Print Spooler adds a registry entry for each redirected printer. These entries are found under the following registry subkey for the user and for all users logged onto the RD Session Host server:

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

The registry entries for these redirected printers are supposed to be deleted when users disconnect or log off. However, in cases where other users may have logged off in the meantime, the registry entries can be leaked into their HKEY_CURRENT_USER registry hive.

Over time, the registry subkey will gather many invalid registry entries for redirected printers. These entries can include permutations of the client name, the printer name, and the session ID. Applications that read this registry subkey will then display these invalid printers to users. It's essential to note that this issue is more likely to affect some legacy applications.

VB Script to Clear Redirected Printers

  1. Create a VB script called delprinter.vbs with the following content:

    In this particular code, the script is accessing the Windows Registry to enumerate and delete specific values related to redirected printers and printer ports. It appears to be targeted at removing registry entries for devices and printer ports that contain the substring "redirect" within an RDP session.
Const HKEY_CURRENT_USER = &H80000001
on error resume next
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Devices"
oReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrDevices
For Each device In arrDevices
if (inStr(device,"redirect")) then
oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,device
WScript.echo "Deleted DEVICE - " & device
WScript.eCho "No Action DEV - " & device
end if
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
oReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrPrinterPorts
For Each printerport In arrPrinterPorts
if (inStr(printerport,"redirect")) then
oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,printerport
WScript.echo "Deleted PRINTERPORT - " & printerport
WScript.eCho "No Action PPORT - " & printerport
end if
  1. Create Group Policy that runs when users log off.
  2. Reference the batch file you created in the previous step.
How Can We Help?
Our team thrives on new challenges. If you have a project in mind or simply want to ask a question, we’d love to hear from you.
Lumitiv is your all-in-one IT department with over 15 years on the job. We help simplify and guide businesses through the technical landscape, turning complex tech into a powerful business asset.
Copyright 2023 Lumitiv
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram