Installing file in users AppData folder using inno-setup

32,435

Solution 1

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

Solution 2

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**

Share:
32,435
JakeSays
Author by

JakeSays

Updated on May 26, 2020

Comments

  • JakeSays
    JakeSays about 4 years

    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