Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing file in users AppData folder using inno-setup

Tags:

inno-setup

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

like image 767
JakeSays Avatar asked Mar 14 '13 12:03

JakeSays


People also ask

How do I add a folder to Inno?

Simply include the recursesubdirs flag to your [Files] section entry. The help says about this flag the following: Instructs the compiler or Setup to also search for the Source filename/wildcard in subdirectories under the Source directory.

What does Inno Setup do?

The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX's and type libraries, and install fonts. Creation of shortcuts anywhere, including in the Start Menu and on the desktop. Creation of registry and . INI entries.

What is Localappdata?

AppData is the folder where Windows saves all the configuration information of the applications installed on your computer, having one for each of the users that you have created. It is to protect user data and settings from any unwanted change or deletion.


2 Answers

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
like image 177
Ravaut123 Avatar answered Sep 21 '22 13:09

Ravaut123


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

like image 45
MSA Avatar answered Sep 20 '22 13:09

MSA