4

Is there some way to set the DefaultDirName by code depending on some decission a user did on installtion?

Let me comment: I have some code which is build for two different systems (using different interops/ocx's and such stuff). My input files are stored in two directories input\A and input\B. I want to have only one setup-file for both systems.

In the setup file i use CreateInputOptionPage with 2 options to determin which files to install (using Check on each file). This works okay.

But i do also have some ShellExec on finish of setup, which at the moment uses {app} to e.g. register some .Net classes and ShellExec to unregister the .Net classes on InitializeUninstall (also uses {app})

The setup must install the software on two different locations (depending on the selection of the user (eg. c:\software_a or c:\software_b). Can't change this.

So is there some way to specify the DefaultDirName before the files get copied to the system, so i can use the same ShellExec on install and uninstall? I could of course add the same ShellExec for both systems on installtation and use an if to check which files to register (depending on the user selection) but on uninstall i would not have this information (user selection), so i can not unregister the .Net classes.

thanks

rene marxis
  • 385
  • 2
  • 13

2 Answers2

4

In your CreateInputOptionPage code section, you might be able to set a value then use that value in the code snippet below. I haven't tested it but it might work.

[Setup]
DefaultDirName={code:getpath}

[Code]
function GetPath( Default: string ): string;
begin

if (CreateInputOptionPageValue1) then
 Result := ExpandConstant({sd}) + '\path1';
else
 Result := ExpandConstant({sd}) + '\path2';
end;
mirtheil
  • 8,952
  • 1
  • 30
  • 29
  • Hello, i tried using the {code:.} for DefaultDirName, but the installer exists with an error. Probably because the value needs to be set before the setup starts and the value from the radiobuttons is present only after the first dialog is shown ... – rene marxis Nov 15 '10 at 06:38
  • 1
    I did it the "manual" way ... specify a {pf}\dir for DefaultDirName (so my uninstaller gets installed there) and do the whole stuff with Desc: {code:...} and Check() in the Files section. Seems to work so far – rene marxis Nov 15 '10 at 06:40
  • Yeah, `Param` cannot be a global. The [Setup Section help](http://www.jrsoftware.org/ishelp/index.php?topic=setupsection) doesn't discuss the use of [parameters in sections](http://www.jrsoftware.org/ishelp/index.php?topic=params), but it might be possible to pass any of the [common parameters](http://www.jrsoftware.org/ishelp/index.php?topic=commonparams). FWIW haven't, for the Setup Section used either a [Check Function](http://www.jrsoftware.org/ishelp/index.php?topic=scriptcheck) or [Before/After Install](http://www.jrsoftware.org/ishelp/index.php?topic=scriptinstall) parameters. – Laurie Stearn Jan 21 '18 at 06:31
1

If you need to change the install folder after the DefaultDirName has been initialized, this was working for me quite well:

procedure CurPageChanged(CurPageID: Integer);
begin
  { updates the install path depending on the install type or the entered suffix }
  if CurPageID = wpSelectDir then begin
     WizardForm.DirEdit.Text := ExpandConstant('{pf}') + '\MyAppName' + GetAppSuffix('');
  end;
end;

Cheers Chris

chris
  • 76
  • 1
  • 3