20

I am using Inno-Setup version 5.5.3(a).

[Files]
Source: "C:\GPT\GPT.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\GPT\GPT.dat"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

I would like to install the "GPT.dat" file into the users AppData folder in a custom folder called "GPT"

e.g. AppData\GPT\

for example, in my delphi code, I create a folder called "GPT" in the users AppData path. These is where I would like to place the file

var
  path: array[0..MAX_PATH] of char;

 SHGetFolderPath(0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT, @path);
 userPath:= Path;
 UserPath:= UserPath + '\GPT\';
 if not DirectoryExists(UserPath) then
   CreateDir(UserPath);

Can anyone tell me how to edit my [Files] section of my Inno script to make this happen?

Thanks

RRUZ
  • 134,889
  • 20
  • 356
  • 483
JakeSays
  • 2,048
  • 8
  • 29
  • 43
  • 2
    Have you looked in the inno-setup documentation? I believe you can find the AppData folder as a macro. http://www.jrsoftware.org/ishelp/index.php?topic=consts {localappdata} & {userappdata} & {commonappdata} are the three AppData folders. – Warren P Mar 14 '13 at 12:55
  • I saw this: https://wiert.me/2017/11/08/innosetup-where-the-appdata-constants-point-to/ – Royi Mar 31 '20 at 17:38

3 Answers3

27

You need to use the {userappdata} constant, which is mapped just to the CSIDL_APPDATA item ID, as a destination directory for your files:

[Files]
Source: "C:\GPT\GPT.dat"; DestDir: "{userappdata}\GPT\"; Flags: ignoreversion createallsubdirs recursesubdirs comparetimestamp

{userappdata} & {commonappdata} The path to the Application Data folder.

 CSIDL_APPDATA = {userappdata} = C:\Documents and Settings\username\Application Data
 CSIDL_COMMON_APPDATA = {commonappdata} = C:\Documents and Settings\All Users\Application Data
Ravaut123
  • 2,764
  • 31
  • 46
  • so where do these two lines go? – JakeSays Mar 14 '13 at 15:23
  • info on http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx – Ravaut123 Mar 14 '13 at 15:33
  • 4
    Note that while it is *possible* to install files to a user's folders during an admin install, it is very strongly discouraged. At most one user will be affected by this, and not necessarily the one that should be. Rethink your design instead of doing this. – Miral Mar 15 '13 at 13:24
  • This answer seems wrong. Are you sure you didn't mean {commonappdata}? – NickG Sep 25 '14 at 13:21
  • **Note**: In versions above Windows XP, `{userappdata}` refers to `C:\ProgramData`, and `{commonappdata}` refers to `C:\Users\Username\AppData\Roaming}`. – the_Ma5TeR Jun 29 '16 at 09:33
  • 5
    @the_Ma5TeR, I just checked on Win8.1 and it's opposite to what you said. `{userappdata}` is `C:\Users\Username\AppData\Roaming` – Dmitriy Aug 02 '16 at 23:28
  • Oh yeah I meant the other way around :p – the_Ma5TeR Dec 02 '17 at 08:45
  • Could someone say the definite answer? InnoSetup documentation doesn't say if `{userappdata}` is `C:\Documents and Settings\username\AppData` or `C:\Documents and Settings\username\AppData\Roaming\`. – Royi Mar 31 '20 at 17:35
6

You need to use : {userappdata}
If you check the Inno Setup documentation :

{userappdata} = C:\Documents and Settings\username\AppData\Roaming\
{commonappdata} = C:\Documents and Settings\All Users\AppData\Roaming\

{localappdata} : The path to the local (nonroaming) Application Data folder.
{userappdata} & {commonappdata} : The path to the Application Data folder.

I use :

[Files]
Source: MyPath\* ;  Flags: recursesubdirs createallsubdirs; DestDir: {userappdata}\MySoftware\ ; Components: ConfigFiles

And my config files are in :

C:\Users*\AppData\Roaming\MySoftware**

MSA
  • 138
  • 1
  • 9
0

It seems more appropriate to use {programdata}, if I interpret Mirals comment correctly.

However, on XP there is no {programdata}, only {commonappdata} or {userappdata}, so I have to diversify my install. {programdata} is a later invention.

A disturbing trap is when the desktop and userappdata are mirrored to the server ("roaming profile"), that slows programs down greatly if they use userappdata for ini file storage, at least that's my experience.

  • Roaming profiles won't slow the application down as they are stored locally and synced with the server on login. If however they are redirected to a netwrok share (not necassarily roaming profiles) then it will slow things down, but this is by design. – Deanna Feb 13 '14 at 10:24
  • 2
    There ain't any constant called `{programdata}`, its actually `{commonappdata}`. It refers to `C:\ProgramData`. – the_Ma5TeR Jun 29 '16 at 09:32