22

Every time I compile my installer the default installation directory is C:\Program Files\Company\Product and I don't seem to be able to change it. Here's what I got under Setup:

[Setup]
AppName=MyProduct
AppVerName=MyProduct
AppPublisher=Company
DefaultDirName=C:\MyStuff\Company\MyProduct
DefaultGroupName=Company\MyProduct
UninstallDisplayIcon={app}\MyProduct.exe
UninstallDisplayName=MyProduct Uninstall
PrivilegesRequired=poweruser
OutputDir=userdocs:Inno Setup Examples Output
OutputBaseFilename=Setup
DisableDirPage=false
DisableProgramGroupPage=true
VersionInfoCompany=Company Inc
VersionInfoProductName=MyProduct
AllowUNCPath=false

Based on the documentations, DefaultDirName should dictate the default install folder. But it doesn't.

My case in particular is that, I want to set the default install folder on x64 machines to C:\Program Files, but the installer always picks Program Files (x86) no matter what I put in the DefaultDirName.

Mossi
  • 997
  • 5
  • 15
  • 28
  • For an x86 app, `C:\Program Files (x86)\` and `C:\Program Files\` are the same folder. – Deanna Mar 25 '13 at 13:49
  • If you have a 64-bit application then you should turn on 64-bit install mode, and then it will do what you seem to want. If you have a 32-bit application then Inno is already doing the right thing, and trying to force it to install to the 64-bit Program Files folder would be very bad. – Miral Mar 25 '13 at 19:49

2 Answers2

37

The last selected installation folder has the precedence before the DefaultDirName directive value if the UsePreviousAppDir directive is set to yes, which is by default. If you want to force the directory specified by the DefaultDirName to be selected, turn off the UsePreviousAppDir directive.

If you want to keep the functionality with the last directory, and just overcome this for your testing, simply uninstall the previous installation before you run the new built setup.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • 7
    Note that you should normally **not** turn off `UsePreviousAppDir`, since doing that breaks user's expectations. Uninstalling first while testing is the correct answer. – Miral Mar 25 '13 at 19:48
  • This `UsePreviousAppDir` default value was perplexing me for 2-3 hours until I found this...thanks..........I copied and pasted my script from my last program version, which I'm just now realizing includes the same `AppId`, presumably leading to this conflict. Using the uninstaller from my old version fixed the issue – velkoon Jan 31 '21 at 01:54
6

Just add "UsePreviousAppDir=no" in your iss file:

[Setup]

...

UsePreviousAppDir=no

SLdragon
  • 1,477
  • 16
  • 19