0

in my setup i need to check if a program is installed and if not i need to install it before my app installation. I don't know how to extract needed files before [Files] section This is my code:

[Files]
Source: "..\PREREQUIREMENTS\DicomObjects\DicomObjectsSetup43.exe"; DestDir: "{src}\PreReq\DO\Setup\"; DestName: "DOSETUP.exe"; Flags: ignoreversion
Source: "..\PREREQUIREMENTS\DicomObjects\License\DicomObjects.lic"; DestDir: "{src}\PreReq\DO\Lic\"; Flags: ignoreversion

procedure CurStepChanged(CurStep: TSetupStep);

begin

  if CurStep = ssInstall then
  begin
    if not FileExists(ExpandConstant('"{pf}\Medical Connections\DicomObjects\DicomObjects.ocx"'))then if MsgBox ('installazione DO', mbInformation, mb_YesNo) = idYes then 
    begin
      Exec(ExpandConstant('{src}\PreReq\DO\Setup\DOSETUP.exe'), '', '', SW_SHOW,ewWaitUntilTerminated, ResultCode);
      Exec('cmd.exe','/c COPY "{src}\PreReq\DO\Lic\*.*" "{pf}\Medical Connections\DicomObjects\"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
    end;
  end;

I also tried this code but not work

function PrepareToInstall(var NeedsRestart: Boolean): String;

begin
    if not FileExists(ExpandConstant('"{pf}\Medical Connections\DicomObjects\DicomObjects.ocx"'))then  
    begin
        ExtractTemporaryFile('DOSETUP.exe');
        Exec(ExpandConstant('{src}\PreReq\DO\Setup\DOSETUP.exe'), '', '', SW_SHOW,ewWaitUntilTerminated, ResultCode);
        Exec('cmd.exe','/c COPY "{src}\PreReq\DO\Lic\*.*" "{pf}\Medical Connections\DicomObjects\"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
    end;
end;
  • Use InitializeSetup to do things as the setup starts. See [Inno Setup = How to copy a file before Setup Start?](https://stackoverflow.com/a/13540439/62576) for an example of doing so. There's also `PrepareToInstall`, which is demonstrated in the examples provided with Inno Setup. – Ken White Jul 03 '18 at 12:20
  • @KenWhite . Unfortunately inno setup examples don't help me tu find best way. I prefer to use `PrepareToInstall` but i can't extract needed files before installation. – Andrea Artoni Jul 03 '18 at 14:11
  • solved extract problem with `ExtractTemporaryFile('DOSETUP.exe');` and then `Exec(ExpandConstant('{tmp}\DOSETUP.exe'), '', '', SW_SHOW,ewWaitUntilTerminated, ResultCode);` – Andrea Artoni Jul 04 '18 at 06:31

0 Answers0