My program is installed with a Visual Studio Setup project. The program, when run, creates a user.config
file in its default location since I'm using Settings. When uninsalling, how do I get the uninstaller to remove that user.config
file?
Also, how do I cause the uninstaller to remove a folder in %AppData%
?
You will need to write a custom task for that - by default (and design) the installer will only remove what it installed, anything that added afterwards is not part of the install transaction. You could maybe try installing a dummy file for the user.config, and you should be able to add the AppData folder in to the install (although it won't be removed if you have added files sitting in it at uninstall time).
Basically, you can't/shouldn't/don't. Here's a repost of my answer to a duplicate of this question...
Removal of all per-user data should be a separate process to the uninstall.
My recommendation (and what we do) would be to create a separate "cleanup" utility that must be run as an administrator and will enumerate through the profiles removing additional user files. Optionally it could also enumerate the users registry hives and removing additional registry keys, etc. One of our clients has their own custom scripts that does exactly that.
I would then provide the customer with this cleanup tool and say after uninstall, if you want to remove all user data then use this.
Consider the following cases
- Customer uninstalls prior to installing a new version
- Major upgrades (which will uninstall the old version so you need to be aware of this)
- Accidental uninstall by a user who shouldn't have done it but had the ability to do so
If you must must must remove the data then the cleanest way to remove this data for all users that I can think of would be to take advantage of Active Setup and use this to trigger a per-user script that runs the next time each user logs on. The data won't be deleted during the uninstall, but at the next logon. And you'll leave a few registry entries lying about, however it would be less likely to cause corruption than enumerating user profiles.
Active Setup
is no longer valid - do we have a working link anymore? –
Longsighted © 2022 - 2024 — McMap. All rights reserved.