Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Inno Setup constant {userdesktop} work in OutputDir directive and how to fix it?

Tags:

inno-setup

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
like image 939
Constantine Ketskalo Avatar asked Jan 01 '26 07:01

Constantine Ketskalo


1 Answers

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
like image 169
Martin Prikryl Avatar answered Jan 06 '26 14:01

Martin Prikryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!