January 9, 2014

RDS and XenApp: How To Prune FontCache Files Under Windows ServiceProfiles Directory

I’m not sure exactly when this started on my Remote Desktop Service (RDS) and Citrix XenApp servers (because it wasn’t always a problem), but on both Windows Server 2008 R2 and Windows Server 2012 I’m seeing a large number of “FontCache” files in this specific location:


Again, this is only a problem on RDS and Citrix XenApp servers. Although it’s entirely possible it happens on other servers, the reason it’s a problem in RDS/XenApp environments is because a “FontCache” file is created for each unique user and these files are at least 8MB in size. If you have thousands of unique users, over time the space on the C: drive begins to fill up. We typically don’t allocate a ton of space for C: drives on these servers, so we’ve had a few instances where FontCache files completely filled the drive. The specific naming convention of these FontCache files is:


Where (SID) is the Security Identifier Definition (without the parenthesis).

Originally I believed these files were being created by a Windows service called “Windows Presentation Foundation Font Cache” But after disabling this service the files still appeared. So now it is apparent these files are being created by the standard “Windows Font Cache Service,” but I have yet to test disabling that service, and I do not yet know what (if any) problems that may cause. So try at your own risk!

But what you can do is manually delete these files from time to time or set up a Scheduled Task to do it for you. Below is the command you can run that will stop the service, delete the files, and start the service again.

net stop fontcache && del C:\Windows\ServiceProfiles\LocalService\AppData\Local\*.* /s /q & net start fontcache

The above command is a single line command even if it appears as more than one line in your web browser. Obviously you can split up the three individual commands (separated by ampersands, && and &) that make up this one long command. But if you are going to manually do this from time to time, it’s easier to copy and paste a single line command.

More information on the use of ampersands in commands:

Multiple Commands on a Single Line May Not Run When You Use the && Command Separator

Please share your thoughts