-1

Im trying to install ndp48-x86-x64-allos-enu.exe on computers that don't have it.

I have both those procedures :

the check function:

function NETFrameworkIsNotInstalled: Boolean;
var
  ver: Cardinal;
begin
  Result :=
    not
    (
    (RegKeyExists(
      HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client')
    and
        RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', 'Release', ver)
    )
    or
    (RegKeyExists(
      HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full')
    and
        RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', ver)
    )
    )
    or (ver < 528040)
end;

and the installer procedure :

procedure InstallNETFramework;
var
  ResultCode: Integer;
  StatusText: string;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing .NET Framework 4.8...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try

// i tried with and without "ExtractTemporayFile() and also tried ShellExec() and Exec(), none work
    ExtractTemporaryFile('ndp48-x86-x64-allos-enu.exe');
    if not ShellExec('open',ExpandConstant('{app}\ndp48-x86-x64-allos-enu.exe'), '/q /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) 
    then
    begin
      MsgBox('.NET Framework 4.8 Installation did not succeed : ' + IntToStr(ResultCode) + '.', mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end;

the checking procedure works perfectly and so the installer procedure runs BUT nothing shows up, eventualy, the step just passes to the next one and it doesn't get installed.

Here are more informations :

[Files] 
Source: "Dependencies\ndp48-x86-x64-allos-enu.exe"; DestDir: "{app}"; Flags: deleteafterinstall; AfterInstall: InstallNETFramework; Components: NETFrameworkComponent; Check: NETFrameworkIsNotInstalled
[Code]
var CancelWithoutPrompt: boolean;

function InitializeSetup(): Boolean;
begin
  CancelWithoutPrompt := false;
  result := true;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID=wpInstalling then
    Confirm := not CancelWithoutPrompt;
end;

Attempts: so far, I've tried the ShellExec() and Exec() function, i though it would be an administrator privilege at first but I have all the right on the device I'm trying to install it on, also, it is not a exe probleme because I tried running it directly with my mouse and it worked perfectly. a window with the quote and a progress bar: Extracting file should appear.

Hugo_vdms
  • 65
  • 6

1 Answers1

0

the switch command line "/q /norestart" was causing all the mess :

"/q" makes the installation silent and doesn't prompt anything to the user. "/norestart" doesn't prompt the user to restart the computer if needed.

"/promptstart" prompts the user to restart if he accepts it.

Hugo_vdms
  • 65
  • 6
  • 1
    Norestart is actually the recommended option in this case, as you want to restart only after the installation (of your app _and_ the framework) are both complete. You can check the return code of the installer and delay the restart until the overall installation is complete. – PMF Dec 09 '22 at 11:51
  • yeah, i'm currently on it but i don't know how to actualy get that result back at the end of the instalation and if so restart it via the final checkbox that curently indicates "lauch the app". is the NeedRestart() function a good way ? – Hugo_vdms Dec 09 '22 at 13:21
  • 2
    I have not found that function, but it seems is that all you need to do is set the property `RestartIfNeededByRun` in the `[Setup]` section to true. That should automatically detect when an installer in the run section requires a restart. – PMF Dec 09 '22 at 13:44
  • Related https://stackoverflow.com/a/74743767/3195477 – StayOnTarget Dec 13 '22 at 13:01
  • @PMF Good point. I've added this to my answer at [How to restart Inno Setup installer based on result of procedure that executes a program/subinstaller](https://stackoverflow.com/q/74742659/850848#74743767). – Martin Prikryl Dec 14 '22 at 07:07