Cleaning a large Windows\assembly\temp folder

I found that one of my servers had very low free space on the C drive, and by using TreeSize I found that 9GB was being consumed by the folder C:\Windows\assembly\temp:
windows assembly temp large

This isn’t supposed to happen, the temp folder is used for .Net Global Assembly Cache (GAC) uninstalls (whereas the tmp folder is used for installs). It seems as though these folders should be tidied up automatically, but clearly sometimes are not.

The assembly folder is also a bit interesting to work with via Windows Explorer. You can do some fiddling around with a desktop.ini file and delete the folders via Explorer, or use my method, which is via the command line. I am doing this to a remote machine – you don’t want to be on the console of a server unless strictly necessary, and this is not one of those times.

pushd \\problemserver\c$\windows\assembly\temp
for /f %i in ('dir /b') do rd /s /q %i
popd

which takes a little while to go through and delete the folders. Some won’t delete, giving Access is denied errors, but most seem to. Here’s an updated TreeSize view of the same server after running the above commands:
windows assembly temp after cleaning

Clearly, if you run an rd /s /q anywhere inside your Windows folder (or anywhere at all, for that matter) you’d better be sure you are in the right place and are happy about the stuff it’s going to delete prior to pushing the button! You are responsible for what you do to your own systems.

This entry was posted in Windows and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s