I created Inno Setup script, which works perfectly, but I wanted to change OutputDir
to create the output file on my desktop. But instead of creating output file on desktop it was creating subfolder {userdesktop}
at the same directory, where script is and output was inside.
I found solution so far, but I believe there should be better way. What am I missing?
; these attempts didn't work
[Setup]
OutputDir={userdesktop}
; some more attampts:
OutputDir=userdesktop
OutputDir=userdesktop:
OutputDir="{userdesktop}"
; this workaround worked for me
[Setup]
OutputDir=userdocs:..\Desktop
Constants like {userdesktop}
are resolved on install time (on the target user's machine), not on compile time (on your development machine). So it makes no sense to use constants in compile-time only directive like OutputDir
. And actually it's not possible to use them at all (as it's useless).
With the default user profile directory layout, use you can use the userdocs:
prefix, as you did:
[Setup]
OutputDir=userdocs:..\Desktop
Though it's not a perfect solution, as the "Documents" folder can be moved by the user and then the userdocs:..\Desktop
will not point to the desktop.
A more reliable solution is to use USERPROFILE
environment variable using GetEnv
preprocessor function:
[Setup]
OutputDir={#GetEnv('USERPROFILE')}\Desktop