The Windows Add/Remove Programs Applet

By Deane Barker on March 3, 2005

I got to wondering the other day how the Windows Add/Remove Programs control panel applet works. It turns out that it’s not that complicated.

The list of programs you can uninstall is stored in the registry under:

Software /
Microsoft /
Windows /
CurrentVersion /

If there’s one there you want to get rid of, just boink the registry key. (If that’s too primal for you, TweakUI supposedly has support for it, though I couldn’t find it. Besides, deleting the keys is what Microsoft recommends anyway — don’t be a wuss.)

Each entry has two subkeys: “DisplayName” and “UninstallPath.” DisplayName is what’s…well, displayed, and UninstallPath is the shell command that’s run when you try to uninstall it. Those are the only two required entires, though there are several more. For instance, here’s the entry for my beloved PowerGrep:

(Where does all this come from? If you use an installer creation program to deploy your app, you can usually specify it in the wizard. Here’s an example from the Installshield documentation. Here’s a list of all the properties in the Windows Platform SDK.)

In the case of PowerGrep, you can see that when you uninstall it, it just runs a program called “Undeploy.exe” and passes it the log of how it installed itself. I took a look in that file, and it’s just what you expect: a list of all the files and registry keys that were installed. This is just one app, of course, but the theory is fundamentally the same for every app.

But how about this piece of magic:

How does this applet calculate the size of the program and how often it’s used? Well, the program can provide this information itself (see the EstimatedSize key in the screen capture above), or Windows can estimate it…poorly. Windows Ninja Raymond Chen provides some insight:

So Add/Remove Programs starts guessing. It goes through all the programs on your Start menu and compares their names with the display name of the uninstallable item. It looks for Start menu items which share at least two words with the words in the DisplayName.

[…] Add/Remove Programs looks in your “Program Files” directory for directories whose names share at least two words in common with the DisplayName. The best match is assumed to be the directory that the program files are installed into. The sizes are added together and reported […]

Eeesh. Ugly. But that’s how it’s done.