Question

In my application, every user has its own settings, that I save to a subdirectory in that user's Application Data directory. During uninstall, I want to delete those settings for every user on the computer. How can I do that in Inno Setup?

In other words, I need to get a list that contains Application Data directory for each user (not the shared Application Data directory), so that I can delete the MyAwesomeApp directory from there. Is there some way to do that?

Was it helpful?

Solution

You can't, due to the design of Windows. The same design stops you accessing the profile folders too.

On top of this, it's accepted best practice to leave the user's data behind in case they want to reinstall it, roaming profiles, etc.

OTHER TIPS

Assuming that your uninstaller runs with administrator priviledges, you can just get the User directory and then enumerate all the user directories there.

You can run an executable from Inno Setup written in whatever language you want. In it you can first get the current user's Application Data directory, using the SHGetSpecialFolderPath function. It would look something like this for Win7:

c:\Users\MyUser\AppData\Roaming\

You can use GetUserName to get the user's name (MyUser in this case), and find the parent directory and split the string to the parent directory "C:\Users\" and "AppData\Roaming\". You can then use FindFirstFile/FindNextFile to enumerate all users directories, and just append the second part "AppData\Roaming\" to them, and check if the file exists. By splitting the directory you get from SHGetSpecialFolderPath you ensure it would work both in XP (which would return something like C:\Documents and Settings\MyUser\Application Data") and in Win7. Basically you just replace MyUser with all the users' names in the string returned by SHGetSpecialFolderPath.

I have no idea if this avoids OS security or if it works with roaming users.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top