Inno Setup User Home Path

2019-02-24 22:53发布

问题:

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.

回答1:

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.



回答2:

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).



回答3:

I support the idea of being able to put files into the user profile directory. The files are not "documents" that would go into the {userdocuments} folder and they are not files to be hidden from the user that would go into {userappdata}. I don't see the logic behind the restriction that microsoft (and inno) seem to be imposing here.



回答4:

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