开发者

How to delete application folder on uninstall

  1. I have created a setup using Setup project in VS 2010. It install my application into program files folder lets say XXX. My application further creates so开发者_运维百科me files and folder into XXX folder. At the time of uninstall it delete every thing whatever create by setup while files and folder created by my application remains there in XXX.

  2. I wrote some custom code to delete the folder (XXX) using installerclass but does not executes when user uninstall from control panel while executed successfully when uninstall from Setup created by me.


The first step would be to modify your application so it writes its data in per-user locations instead of the application folder. For example, you can use a custom folder in the current user AppData directory. This way you avoid permission-related problems.

For removing this folder, you can indeed use a custom action. If it's added under Uninstall in your setup project, it should run for both Control Panel and package uninstalls.

Try creating a verbose uninstall log and search for your custom action name to see what happens.


I don't think you should write any custom code for that, if all your files are marked as temporary and not permanent, this will be handled directly by the MSI engine.

Play with the configuration and properties of folders, files and the setup project itself and you will get what you need with no code to be written.


My guess is that your Custom Action for removing files is scheduled in UI section. When uninstall is started from Control Panel, it runs in minimal UI mode, and all your dialogs are skipped.

Your Custom Action must be scheduled in InstallExecute table.
(To be compatible with UAC, it must be deferred with noimpersonate. Yet your application itself is not compatible with UAC, so it does not really matter.)


DON'T DO THIS! First, users usually don't appreciate having their data files they put in the application directory deleted without warning (they might only be uninstalling it because they want to move it to a different drive, for example). It's better to leave it up to the end users to manually remove them if they want. Also, if the user happened to install the program in the wrong directory by mistake (for example, C:\WINDOWS) and then went to uninstall it there could be disastrous consequences. Or what if the user hides his precious porn videos inside the application folder? So again, DON'T DO THIS!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜