Why does my program still show up in the Programs and Features folder after my uninstaller exits?
A customer reported that they were having problems with their program entry in the Programs and Features folder (formerly known as Add and Remove Programs, formerly known as Add/Remove Programs). When the user goes to the Programs and Features folder, selects their program, and clicks Uninstall, the uninstaller runs, but after the uninstaller exits, their entry remains in Programs and Features. They have to manually refresh the folder to get it to disappear. Why won’t the item disappear? The Programs and Features folder launches your uninstaller and waits for it to exit, at which point the Programs and Features folder looks to see if the uninstall entry for your program still exists in the registry. (There is no standard method for an uninstaller to report success or failure back to their caller, so this is the only technique available.) If the registry entry has been deleted, then the Programs and Features folder concludes that the program was successfully uninstalled and removes the item from view. The trick is the “waits for it to exit” part. If your uninstaller in turn launches another program to do the real work of uninstalling, the Programs and Features folder doesn’t know or care. It just waits for your uninstaller to exit. If your uninstaller exits before the uninstall is complete (because it handed off the work to some helper process), then when the uninstaller exits, the Programs and Features folder looks for the uninstall entry in the registry, finds that it’s still there (because your helper is still running), and concludes that the uninstall was unsuccessful.
Sadly, as is not uncommon, the customer replied with additional information that indicated that they didn’t understand the explanation.
Thanks. We logged all accesses to our uninstall key, and we found that the key is accessed by two processes: explorer.exe and msiexec.exe. The last access is from msiexec.exe. A log file has been attached for reference.
Yes, this is completely consistent with the uninstaller exiting before the helper (here: msiexec.exe) finishes its work. The Programs and Features folder (running inside explorer.exe) checks the key, finds that it’s still there, and leaves the item in the view. And then msiexec.exe finishes its work and deletes the key. But by then it’s too late; the Programs and Features folder already concluded that the uninstall was unsuccessful. Bonus chatter: Why doesn’t the Programs and Features folder wait until the uninstaller and all its child processes exit? Because that doesn’t work either. It is common for installers to launch child processes that it intends to outlive the installer. For example, it might end with a dialog box that says, “Congratulations, your install was successful. Do you want to run the program now?” Or it might launch some background task to create an annoying notification icon.
Anything an installer does, an uninstaller can do, because one of the options in the uninstaller might be Repair or Reinstall. If the Programs and Features folder waited for all child processes to exit, then it might end up concluding that the uninstaller never finished because some random background task is still running.