Could you tell me please. I wrote an application that uses 'Settings.ini' to save settings. The application is installed using InnoSetup. If there are several user accounts and the application is installed in one of them, so, if I try to run the application from another account I get error "Unable to write to....". That is, if run from another account, the application has no rights to write to the settings file. I don't know what happens in Windows XP, but that's the way application behaves in Windows 7. So could you tell me please, is there something I should define in my application to make it work for multiple users or it should be changed during the installation, somewhere in InnoSetup parameters? Thank you.
-
2Where do you save the settings.ini? Do you use the correct user-specific directory f0r application data? use ShGetSpecialFolderPath(0, path, CSIDL_Personal, False) for example... – Andreas Jan 18 '13 at 09:56
-
1And where did you install the exe? – David Heffernan Jan 18 '13 at 10:16
-
@Andreas i think it is easier to get the path via GetEnvironmentVariable http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms683188.aspx for 'APPDATA' or 'USERPROFILE' or 'LOCALAPPDATA' – Arioch 'The Jan 18 '13 at 10:21
-
2@Arioch'The: `GetEnvironmentVariable()` is not better than `SHGetSpecialFolderPath()` or `SHGetKnownFolderPath()`. A process's environment is dynamic and customizable. It is even possible to have your app run with a non-standard environment block. The Shell functions get their values from the OS instead, so they are less likely to be tampered with, and they are more future-proof when APIs change. – Remy Lebeau Jan 18 '13 at 18:17
-
They are less x-platform, and if environment was tampered - then that is what user(or admin) wants. – Arioch 'The Jan 20 '13 at 09:43
-
EXE file is installed to Program Files folder and 'Settings.ini' file is also copied to the same folder. That is, I use only one 'Settings.ini' file. I do not create separate ini file for every user. So that when my application is installed from "User1", if I run then from "User2", my application is not able to write to the ONLY ONE 'Settings.ini' file, because it was installed (copied during installation) when "User1" was logged in. So how can I let my application modify the ini file that was copied when another user was logged in.??? – serhiyiv Jan 20 '13 at 17:23
1 Answers
You should - install the very program into Program Files or some other common folder - folder that any user have rights to read and run, but not to write or delete. USually installers would allow to override the folder, but the rule remains: every user should have non-destructive rights (read and execute) and none - destructive (delete, overwrite)
That means your installer should request Admin rights and UAC Elevation - ask InnoSetup forum or documentation how to do it. That may deal with including manifests resources into installer. It is normal when a regular user runs the installer and installer then asks for another username and password with admin rights.
The settings and other user-unique data should be saved into special per-user data folders. Usually that is AppLocal folder under user profile. However it is task for your application rather than the installer. Installer may create global settings templates, that the application would just copy into user-local settings on the 1st run under given user, or would override by user-local settings if cascading settings storage is implemented.
- http://msdn.microsoft.com/en-us/library/windows/apps/hh465094.aspx
- http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx
Run command prompt, issue set
command - and u would see all needed paths as environment variables wit hnames like AppPath, LocalAppPath and UserProfile

- 15,799
- 35
- 62
-
1If you want your ini files to apply on a per user basis, I suggest you not create ini files using Inno Setup. Instead, when a user runs your program, check for the existence of the user's ini file. If it doesn't exist, let your program create a per user folder (e.g., %USERPROFILE%\AppData\Roaming\
\ – Max Williams Jan 18 '13 at 12:54\) and create the user's ini file in this new data folder. -
@MaxWilliams i rephrased. I mixed responsibilities of installer and applications. Thanks for correction. – Arioch 'The Jan 18 '13 at 13:00