views:

1305

answers:

3

I am using Inno setup to install a product of mine, in the setup I execute an extern program (Validator.exe) if this program is canceled or aborted I have to cancell my own installer.

I save the Validator.exe in {app} path and the execute it.

When the installer is running I call Validator.exe file and I get the result of the execution with: Exec(ExpandConstant('{app}/Validator.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode).

But this are the problems with all the solutions that I have tried:

InitializeSetup: The Validator.exe File is not copied in {app} yet, so it will never be executed.

Abort:can be called only in (InitializeSetup,InitializeWizard,CurStepChanged(ssInstall)) so in these cases the Validator is not copied yet.

DeinitializeSetup: I can execute Validator.exe after the installation but I can't abort the my installer from this point.

I need some way to cancel the installation after Validator.exe has been copied and executed, maybe call uninstall but I couldn't do it.

Thanks for any help.

+2  A: 

In Inno Setup, an "external" file is one that is not included within the installer EXE file. It exists externally, presumably included as a separate file with the installer EXE file. You say your reason for not calling Abort within the InitializeSetup event is that the validation program hasn't yet been copied to the {app} directory, which is understandable since at that point, the user hasn't yet specified what the installation destination should be. But you don't need the validator be be in the destination directory. It's already an external file, so simply run it from whatever directory it's already in.

Another possibility is to put the required validation functionality into a DLL. You can include the DLL in the installer, and Inno Setup will extract the DLL to a temporary location so that you can call its functions from the install script.

Rob Kennedy
+3  A: 

You could simply use the ExtractTemporaryFile() helper function to extract validator.exe at any earlier installation step. See the question inno setup extracting files at the start up setup instead of the end and my answer to it.

mghie
+1  A: 

Thanks it works excellent. This is how I fixed it:

function InitializeSetup(): Boolean;.
var
  ResultCode : Integer;
begin
  Result := True;
  ExtractTemporaryFile('Validator.exe');

  if Exec(ExpandConstant('{tmp}\Validator.exe'), '', '', SW_SHOW,
    ewWaitUntilTerminated, ResultCode)
  then begin
    if not (ResultCode = 0) then begin
      Result := false;
    end;
  end;
end;
Ubalo