7

I would like my installer to put some files into a users home path, (the path that the Windows %USERPROFILE% environment variable points to, and the path Qt's QDir::homePath() returns).

I have looked at the Inno Setup Constants page, but can't find the path I am looking for.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
oggmonster
  • 4,672
  • 10
  • 51
  • 73
  • 5
    You should never put files in the root of a user profile directory. – ZippyV Jul 15 '13 at 14:23
  • Also, installers (that install per-machine, which is the default) should never write files in per-user folders anyway. Leave that to the application. – Miral Jul 15 '13 at 20:57
  • @ZippyV I think it is not right to forbid something generally. I want to add ssh key which has to be added to HOME/.ssh/ folder and I would like to create this folder as well from inno setup if its not there so I think there could be legit need. – zar Jul 09 '15 at 20:33
  • @zadane What happens if a different user launches your application? Even if you have no choice (because of SSH's bad behavior) you should still not do it during install time because a different user might use your application as well. – ZippyV Jul 10 '15 at 15:37

3 Answers3

33

Use environment variables {%USERPROFILE} or {%HOMEPATH}.

Update

As Martin pointed out in the comments, {%HOMEPATH} shouldn't be used because it has no disk name (e.g., \Users\username).

Andreas
  • 506
  • 4
  • 6
  • how to expand those vars? – Arnold Roa Sep 13 '16 at 00:17
  • 3
    Not `HOMEPATH`! `HOMEPATH` variable value is like `\Users\username`. There's no drive in the path. So it will not do, what you want, unless you run the installer from `C:` drive. You want to use `USERPROFILE` variable only instead, which is like `C:\Users\username`. – Martin Prikryl Aug 25 '17 at 06:58
3

For user specific application data you should use the constant {userappdata} which points to the application data folder. In this location you can create a folder for your application to store user specific files in.

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
  • 2
    Even though this doesn't directly answer the question asked here, I'm voting this up since it is true, that for user specific application data should be used folder pointed by the `{userappdata}` constant. – TLama Jul 15 '13 at 20:28
1

Updates from @Andreas, suppose you have a file with contents and it needs to be set to users home directory

1) C:\Users\sun\Desktop\.appcfg_nag:

opt_in: false
timestamp: 0.0

2) InnoSetup you can do like below copy paste:

[Files]
Source: "C:\Users\sun\Desktop\.appcfg_nag"; DestDir: "{%HOMEPATH}"; Flags: ignoreversion

Now, the file .appcfg_nag will be located in C:\Users\sun\.appcfg_nag

  • 1
    `HOMEPATH` variable is like `\Users\username`. There's no drive in the path. So your entry will not do, what you want, unless you run the installer from `C:` drive. You want `USERPROFILE` variable instead, which is like `C:\Users\username`. – Martin Prikryl Aug 25 '17 at 06:54