1
votes

I have an Inno installer for my main application. A feature can also be separately installed with another Inno installer, but I want it to copy its files into the main application's install folder. To do this, {app} for both installers is set to the exact same hardcoded value.

My problem is that the second installer will fail either due to an access denied error on the {app} directory, or it will totally obliterate the contents of the {app} directory.

Is there a way for two installers to share the same {app} folder? Note that it is important that the feature be a separate installer so it shows up in Control Panel, and I need them to share the same {app} folder for design reasons. It would also be nice if the feature could be installed before the main application, and if the feature is uninstalled last, it will delete the install folder.

2
Using the same {app} won't cause the second installer to "fail either due to an access denied error on the {app} directory, or it will totally obliterate the contents of the {app} directory." - Your problem is most probably different. We need minimal reproducible example.Martin Prikryl
You're right - I should know better. I could not reproduce this with a stripped down install. I will post the answer once I figure out what's going on.Dan

2 Answers

1
votes

I can't exactly explain the "access denied" error, but the fact that one installer appeared to remove the other was because the main installer incorrectly included the files that the feature installer did.

0
votes

Based on How to force Inno Setup to set the installation folder dynamically:

Use a scripted constant to set the DefaultDirName directive to point to the path, where the main application is installed.

[Setup]
DefaultDirName={code:GetDefaultDirName}

[Code]

const
  MainAppId = 'My Program';
  MainAppRegKey =
    'Software\Microsoft\Windows\CurrentVersion\Uninstall\' + MainAppId + '_is1';
  SetupAppPathValueName = 'Inno Setup: App Path';

function GetDefaultDirName(Param: string): string;
begin
  if (not RegQueryStringValue(HKLM, MainAppRegKey, SetupAppPathValueName, Result)) and
     (not RegQueryStringValue(HKCU, MainAppRegKey, SetupAppPathValueName, Result)) then
  begin
    SuppressibleMsgBox('Application is not installed.', mbError, MB_OK, MB_OK);
    Abort();
  end;
end;

You will probably also want to use the DisableDirPage directive to prevent an user from modifying an installation path.

[Setup]
DisableDirPage=yes