cbono
Posts: 42
Joined: Thu Aug 14, 2008 10:11 pm

Uninstall: MSI removes user's Desktop folder?

Hello all,

This issue doesn't appear to be related to Advanced Uninstaller, but maybe to the MSI technology itself. Maybe someone here can help me find the answer.

Our current product uses an MSI installer built with Visual Studio. At install, we place a Shortcut on the user's desktop to launch the application (it is an advertised shortcut). On an XP system, this location corresponds to C:\Documents and Settings\<user>\Desktop.

If there are no other items in the Desktop folder (other than our shortcut), and I uninstall the product via Add/Remove Programs, the uninstall process deletes the Desktop folder too! If there is at least one other item in the folder, the folder is not removed.

This is especially a problem if the uninstall happens during an Upgrade. The old product is removed first, then as the new product is installed, errors are generated because the Desktop folder doesn't exist anymore.

Admittedly, a scenario where a REAL user has no items in the Desktop folder is very rare. I only found it because I began testing in a virtual environment and it is easy to roll back my OS image to a "base" clean Windows install. It still troubles me though.

Has anyone else seen this behavior? If so, were you able to develop a workaround?

Regards,
Chris
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Uninstall: MSI removes user's Desktop folder?

Hi Chris,
If there are no other items in the Desktop folder (other than our shortcut), and I uninstall the product via Add/Remove Programs, the uninstall process deletes the Desktop folder too! If there is at least one other item in the folder, the folder is not removed.
Please note that this is the normal Windows Installer behavior. If the installation folder remains empty after the files are uninstalled, there is no reason to leave it empty so Windows Installer removes it. If this wasn't the normal behavior, every MSI uninstall would leave empty folders on the user's machine.
If so, were you able to develop a workaround?
A solution would be to create a temporary file in the target folder. This file can be created when an uninstall is triggered and it can be removed after the uninstall process is complete. Please note that the Write text into a file how-to can help you create a file through a custom action. Also, you can use the Remove a file or a folder how-to to create a custom action for removing the file.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
cbono
Posts: 42
Joined: Thu Aug 14, 2008 10:11 pm

Re: Uninstall: MSI removes user's Desktop folder?

Hi Cosmin,

I appreciate the insight. I had always thought that the MSI kept track of which files and folders it created, and those were the only ones the MSI was allowed to remove on uninstall. It seems weird that it would be allowed to remove folders that it didn't create, regardless of whether or not the folder is empty.

I don't see this behavior with the Advanced Installer, though. It installs a shortcut into the "All Users" Desktop folder. Yet when I remove it on a clean OS, that folder is left alone even though it is empty. The problem seems isolated to our old installer package.

But I will look into implementing your suggestion.


Thanks,
Chris

Return to “Common Problems”