My program creates files in c:\Users\GameDev\AppData\Local\<my game folder>
. Is it possible to tell the InnoSetup to delete the entire folder during the uninstallion process, even though the installer didn't put it there ?
Asked
Active
Viewed 1.7k times
19
-
Do you mean, that you want to delete *some* directory, not related to your installer ? – TLama Nov 24 '12 at 18:00
-
Yes that's correct. At the point of installation, this folder doesn't exist as it's created at runtime by my program. – superwpf Nov 24 '12 at 18:02
-
It's the task for [`[UninstallDelete]`](http://jrsoftware.org/ishelp/topic_uninstalldeletesection.htm) section, but you'll have a problem to get always the correct user application data path. – TLama Nov 24 '12 at 18:14
-
Thanks that seems to be a good starting point. – superwpf Nov 24 '12 at 18:25
-
It's also the endpoint, but sorry I missed that you're using local application data. Answer will come in few seconds... – TLama Nov 24 '12 at 18:39
-
1Note that the uninstaller will only be able to delete user files of at most one user (it can't clean up files owned by other users). And the general recommendation for user data is to not remove it at all -- after all, the user might be annoyed at losing data if they're just uninstalling to reinstall at some later time. – Miral Nov 25 '12 at 09:04
-
@Miral Both good points, but I'll be asking the user if they want to remove that data or not before uninstalling. – superwpf Nov 25 '12 at 13:46
-
2In that case, you can't use `[UninstallDelete]` anyway. The Check parameter is tested at install time, not uninstall time; there's no way to make this conditional at uninstall time. You have to use `[Code]` instead. – Miral Nov 25 '12 at 21:33
-
Thanks, I wasn't aware of that. I haven't looked at [code] in any real depth yet, but thanks for the pointer. – superwpf Nov 25 '12 at 21:35
1 Answers
32
To delete certain folder not related to your installer (since, if you don't explicitly specify that, all the files and directories are removed by the created uninstaller), use the [UninstallDelete]
section. There you can specify something like this for your case:
[UninstallDelete]
Type: filesandordirs; Name: "{localappdata}\<my game folder>"

TLama
- 75,147
- 17
- 214
- 392
-
This doesn't work for multi-user installs with separate settings, though, where each user has his own settings in a {userappdata} folder for the program. When tackling this problem, I had to make my program keep a list under {commonappdata} of the settings folders of all users who had started up the program (and, by doing that, created the aforementioned settings folder). This list was then used to remove all these folders by starting an inbuilt uninstall routine in the app itself, which was launched from [UninstallRun] in the Inno uninstaller by starting the app with a command line parameter. – Nyerguds Nov 27 '13 at 08:55
-
@Nyerguds, I doubt you needed to start an external program for this. Many things you can write in a code section of the script. But anyway, the point of this answer was to use `[UninstallDelete]`. Where do you store your data is upon you. And since OP chose the user's application data folder, I just followed this choice. – TLama Nov 27 '13 at 09:05
-
1@TLama For the deleting, true, but the storing of the folder paths needed to be done by the program itself anyway (I spent a lot of time looking for a way to loop over all users from inno, and found nothing), so this seemed the most elegant method. I strongly prefer coding in C# over Inno's pascal script :). As for the question, my remark was simply to point out that Inno has very poor support for user folders in multi-user installs. – Nyerguds Dec 05 '13 at 10:47
-
@TLama, what do u think about [this question](http://stackoverflow.com/questions/28928772/inno-setup-error-handeling-ignore-in-run-section-commands)? – Ramin Bateni Mar 08 '15 at 16:27