How to remove Settings when uninstalling
Asked Answered
B

2

6

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%?

Bors answered 23/4, 2010 at 13:29 Comment(1)
possible duplicate of #511222Roxie
B
3

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).

Bust answered 23/4, 2010 at 13:53 Comment(2)
Problem is I don't know the exact location of the settings file. It sits in AppData\Local\<Company>\<ExeFileName>_<SomeRandomStuff>\<Version>\user.configBors
Then a custom uninstall action will be your best option. It can be real simple, just a script, and you can do a wild card delete of %AppData%\Local\<Company> down.Bust
R
1

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.

Roxie answered 27/4, 2010 at 6:38 Comment(1)
The link to Active Setup is no longer valid - do we have a working link anymore?Longsighted

© 2022 - 2024 — McMap. All rights reserved.