I'm trying to create a setup file using Inno Setup Compiler, and I want it to install to the Documents folder as it needs to create and then delete a file, something that it can't do if it installs to Program Files. I've tried using %userprofile%\\Documents
as that works in File Explorer, but that simply creates a folder called %userprofile%
wherever the Setup.exe is, and C:\\Users\\%username%\\Documents
simply creates the %username%
folder in the Users folder. How do I get it to install into the Documents folder no matter where it is?
While @GTAVLover is right, you will most probably want to use the {userdocs}
or {commondocs}
constant in standard Inno Setup sections, likes [Files]
.
The syntax is like:
[Files]
Source: "readme.txt"; DestDir: "{userdocs}"
Had you wanted to refer to environment variables (what is not the right way in this case), use {%NAME}
syntax:
[Files]
Source: "readme.txt"; DestDir: "{%USERPROFILE}\Documents"
You should use Inno Setup Shell Folder Constants to do this.
See more at Inno Setup Help.
Use ExpandConstant('{userdocs}')
where you want to get path of Documents folder (For current user).
It will return "OS Drive:\\Users\\CurrentUser\\Documents"
.
Eg:
MsgBox(ExpandConstant('{userdocs}'), mbInformation, MB_OK);
For all users, you should replace userdocs
with commondocs
.
So, It will return "OS Drive:\\Users\\Public\\Documents"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.