by: Helge, published: Jul 5, 2011, updated: Sep 6, 2011, in

Script Deletes Orphaned Printer Ports

The script published in this article was kindly contributed by Bo Riis, a sysadmin working at Danish hosting company dandomain. Here is what he writes about it:

Recently I had some issues with MS Office getting really slow on some of our customers’ terminal servers. After some intensive debugging we came to the conclusion that when users disconnected a session they left behind their open printer ports. It seems like that these ports don’t get cleaned up after a while, like the session they belong to. These ghost ports linger and use more and more resources in the print spooler and Office does not react well to a busy print spooler. One of our servers had more than 3000 of these orphaned ports. [Whoa!]

After searching a little we found one reference to this problem on Brian Madden’s forum. From the scripts there I compiled a script that works on Windows XP and up.

We now have this running on almost 200 TS and the users have given positive feedback on performance gains. Depending on how well or bad behaved they were in logging off in the first place.

Bo runs this script weekly on their terminal servers under the system account. There are two versions which are identical except for the logging capabilities.

Download

CleanupOrphanedPrinterPorts.zip
CleanupOrphanedPrintersWithLogfile.zip

Previous Article DsGetDcName Timeout
Next Article Dinosaurs on Your Hard Disk: Historical Files in Windows 7 Everybody Seems to Have Forgotten About