Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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

share|improve this question
2  
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} & {userappdata} & {commonappdata} are the three AppData folders. – Warren P Mar 14 '13 at 12:55
up vote 9 down vote accepted

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
share|improve this answer
    
so where do these two lines go? – JakeSays Mar 14 '13 at 15:23
    
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
1  
@the_Ma5TeR, I just checked on Win8.1 and it's opposite to what you said. {userappdata} is C:\Users\Username\AppData\Roaming – geotavros Aug 2 at 23:28

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.

share|improve this answer
    
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
    
There ain't any constant called {programdata}, its actually {commonappdata}. It refers to C:\ProgramData. – the_Ma5TeR Jun 29 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.