How can I uninstall Win32 assemblies and cleanup WinSxS?
Asked Answered
I

6

11

After a lot of trial and error (mostly due to lack of documentation and examples) I have managed to create MSI installers that install custom DLLs to WinSxS as side-by-side assembly. There is only one problem: Uninstalling leaves all files (DLLs, manifests and catalogs) in the WinSxS directory. How can or should I best clean that up? I know for sure that nothing else references it.

I have read somewhere that WinSxS has a self-scavenging process that cleans up over time but I could not find more information about that. Can you manually invoke this to clean up stuff?

The only other way I see is manually deleting those bits. First you have to change the owner of all files (assembly, catalog, manifest and their respective directory) from SYSTEM to an administrator account, adjust the permissions and delete them. There are also pieces left in the registry (I think HKLM\COMPONENTS\DerivedData\Components may be one place), but since WinSxS should be treated as opaque it is hard to find any information.

Igor answered 8/2, 2009 at 16:11 Comment(0)
L
5

Scavenging isn't exposed anywhere that I know of. I'm not even sure when it is kicked off automatically. Maybe on uninstall of a service pack? Maybe some tool admins can run? I really forget.

Anyway, my suggestion is don't fight it. There are so many twisty turns down there that it just isn't worth trying to get the disk space back. Once uninstalled the bits still in the SxS cache will not be activated so they are just wasting space.

It's a dumb design but blame Microsoft and don't try to overcompensate.

Librettist answered 8/2, 2009 at 17:24 Comment(0)
H
5

Here is an article, it's kinda complete guide to WinSxS.

So, shortly, you can only uninstall some components (all their versions are in this folder), and you can run Service Pack bridge burning utility (in Vista it is named VSP1CLN.EXE and shipped with SP1). Note, that after execution, you shouldn't be able to uninstall SP or any components to state, prior to SP release date.

Handcart answered 31/8, 2010 at 15:8 Comment(0)
B
3

No-one is convinced you can - short of a complete reinstall, your bloaty WinSxS directory is there to stay.

There's been a long "discussion" of the problem on technet.

There is no documentation of the format, or any instructions how to remove files that are no longer needed - MS seems to think that disc space is cheap. There is a self-scavenging feature, but no-one's convinced it works, or if it does, it is very conservative (as you'd hope as you don't want it to break your OS)

You can tell is the scavenger is working by checking the "C:\Windows\winsxs\Temp\PendingDeletes." folder, as this is where files are moved by windows update or an installer moves them to - the scavenger just deletes the files in here.

Beanie answered 8/2, 2009 at 17:24 Comment(1)
Interestingly, I have a bunch of files from 2009 in there. Apparently I've disabled whatever triggers the scavenging. Did you ever find any more details on the process, like what triggers it?Parboil
T
3

You'll notice that after you uninstall your assembly, while the files are still there, they can no longer be bound to - so they are just "staged", or cached, but not really installed.

Rob & gbjbaanb are correct - you cannot manually invoke a scavenge yourself. Don't try to delete the files yourself - there are multiple places in the registry where they are registered, DerivedData\Components being only one of the many references.

I think the rule for Vista is scavenging is kicked off by the TrustedInstaller service after 10 minutes of machine inactivity, after the last servicing operation (service pack, hotfix, etc). But it's very fickle, so it doesn't run as often as it should. So just be patient, and the files will disappear on their own.

Tidings answered 13/2, 2009 at 8:50 Comment(2)
Great info, thanks Eugene. Can I ask what is up with Gabriel's answer about "DISM.exe"? Is this an acceptable diet for the WinSxS folder? :-)Intercellular
I have this answer on disk reclamation here where I mention DISM.exe in the section "Scavenging / Putting WinSxS on a Diet".Intercellular
C
2

Well i was having some issues as i have an 80GB SSD for my windows and the WinSxs folder was about 12gb's

I was searching the net and i found this command:

DISM.exe /online /Cleanup-Image /spsuperseded

And now my WinSxs is 7gb which was wonderful news.

Carat answered 27/3, 2012 at 6:28 Comment(0)
P
0

There are a few updates regarding the cleanup method that apply to newer OS. Check http://www.karafilis.net/winsxs-cleanup

Phellem answered 25/9, 2013 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.