InnoSetup where the *AppData constants point to
Posted by jpluimers on 2017/11/08
The paths are on a standard Windows 7 x64 machine installed on the C: drive. More recent versions of Windows should use the same place.
I’ve not been able to verify this in a domain situation with roaming profiles and redirected folder paths. If anyone has info on that, please let me know.
Anyway, I’ve made some the constants into a table:
| Inno Setup constant [WayBack] |
Windows 7 directory | KNOWNFOLDERID [Archive.is] |
CSIDL (<= Vista) [WayBack] ([WayBack]) |
Environment variable [WayBack] |
System.Environment.SpecialFolder [WayBack] |
|---|---|---|---|---|---|
| commonappdata | C:\ProgramData | FOLDERID_ProgramData | CSIDL_COMMON_APPDATA | ALLUSERSPROFILE | System.Environment.SpecialFolder.CommonApplicationData |
| localappdata | C:\Users\<UserName>\AppData\Local | FOLDERID_LocalAppData | CSIDL_LOCAL_APPDATA | LOCALAPPDATA | System.Environment.SpecialFolder.LocalApplicationData |
| userappdata | C:\Users\<UserName>\AppData\Roaming | FOLDERID_RoamingAppData | CSIDL_APPDATA | APPDATA | System.Environment.SpecialFolder.ApplicationData |
One day I might find time to make this table more complete.
Until then, the code is somewhere around theses pieces of code:
- https://github.com/jrsoftware/issrc/blob/master/Projects/Main.pas
function GetRealShellFolder(const Common: Boolean; const ID: TShellFolderID; ReadOnly: Boolean): String;FolderIDs: array[Boolean, TShellFolderID] of Integer = (
{ User }
(CSIDL_DESKTOPDIRECTORY, CSIDL_STARTMENU, CSIDL_PROGRAMS, CSIDL_STARTUP,
CSIDL_SENDTO, CSIDL_FONTS, CSIDL_APPDATA, CSIDL_PERSONAL,
CSIDL_TEMPLATES, CSIDL_FAVORITES, CSIDL_LOCAL_APPDATA),
{ Common }
(CSIDL_COMMON_DESKTOPDIRECTORY, CSIDL_COMMON_STARTMENU, CSIDL_COMMON_PROGRAMS, CSIDL_COMMON_STARTUP,
CSIDL_SENDTO, CSIDL_FONTS, CSIDL_COMMON_APPDATA, CSIDL_COMMON_DOCUMENTS,
CSIDL_COMMON_TEMPLATES, CSIDL_COMMON_FAVORITES, CSIDL_LOCAL_APPDATA));
FolderConsts: array[Boolean, TShellFolderID] of String =
(('userdesktop', 'userstartmenu', 'userprograms', 'userstartup',
'sendto', 'fonts', 'userappdata', 'userdocs', 'usertemplates',
'userfavorites', 'localappdata'),
('commondesktop', 'commonstartmenu', 'commonprograms', 'commonstartup',
'sendto', 'fonts', 'commonappdata', 'commondocs', 'commontemplates',
'commonfavorites', 'localappdata'));
- https://github.com/jrsoftware/issrc/blob/master/Projects/SetupTypes.pas
TShellFolderID = (sfDesktop, sfStartMenu, sfPrograms, sfStartup, sfSendTo, sfFonts, sfAppData, sfDocs, sfTemplates, sfFavorites, sfLocalAppData);
Note that the installer usually should not fiddle with localappdata or userappdata: that’s the work of the application itself; the installer should use commonappdata see for instance [WayBack] Re: {userappdata} problem on Vista/UAC:
What you should do is to copy *template* files (or no files at all, if their contents can be embedded into or reconstructed by the app itself) into {app} (or under {commonappdata}). When your app starts up, first try to load the files from {userappdata}; if they're not there, load them from {app}/{commonappdata} instead. Always save files to {userappdata}, regardless of where they were loaded from; treat the ones in {app}/{commonappdata} as read-only.
Your installer should avoid touching user paths ({user*}, HKCU) at all; that's your app's job.
Other links that helped me:
- [WayBack] Warren Postma in [WayBack] Installing file in users AppData folder using inno-setup – Stack Overflow:
Have you looked in the inno-setup documentation? I believe you can find the AppData folder as a macro. jrsoftware.org/ishelp/index.php?topic=consts {localappdata} are the three AppData folders. – Warren P Mar 14 ’13 at 12:55
- [WayBack] windows – INNO Setup always installs into admin’s AppData directory – Stack Overflow (TL;DR: using
userappdatameans it will install in the directory of the effective user which might be a different one than you if one needs to go past the UAC prompt)
–jeroen






Leave a comment