Differentiating between uninstalling/installing and upgrading an application

So, I have this application for which we are producing further development versions.

If the application gets uninstalled by the user (from Add/Remove Programs let's say), then I want the application to delete a certain folder in the file system which contains app-related information.

However, if the application is upgraded (by downloading a newer installer for this app and installing it), then I want it to keep that folder.

I am under the impression (at the moment) that it is not possible to differentiate between uninstalling/installing and just updating an application from one version to another, because the .NET deployment projects treat upgrading as just another uninstall/install procedure, but this should be possible somehow.

Thanks for taking the time and whatever answers I may get.


The installer has three GUID codes, ProductCode, PackageCode and UpgradeCode that you can use to manage these scenarios: The UpgradeCode is like an application id and shouldn't change between versions; the PackageCode identifies a release of your setup and the ProductCode identifies a release of your software. You can change the ProductCode by incrementing the ProductVersion value.

Windows uses the ProductCode to see if the application is already installed on a system. If you reinstall using an installer with the same ProductCode and PackageCode you get a Repair/Uninstall option.


This is not a direct answer, but have you considered using third-party installation software? We use InnoSetup for distributing a .Net application, and we find it fairly easy to use and very flexible. It could certainly handle what you are describing.


Have you tried using the ClickOnce deployment? It handles all the install and upgrading of the application. By changing the publish status of the files included in the update you can control if the file gets overwritten with an update or stays the same. When the application is uninstalled all the files will be removed.

链接地址: http://www.djcxy.com/p/3448.html

上一篇: 为什么SqlConnection和SqlTransaction都存在于SqlCommand构造函数中?

下一篇: 区分卸载/安装和升级应用程序