Cancel installation in [Run] section

257 views
Skip to first unread message

Charu Vasudev

unread,
Sep 15, 2023, 9:39:59 AM9/15/23
to inno...@googlegroups.com

Hi,

 

I am using Innosetup to install an msi(made using visual studio)  based on certain conditions. The conditions are evaluated correctly and Msi is able to run successfully. The interface of MSI installation has a cancel button. If I click on cancel button in msi, I want innosetup installation to stop and roll back. Project requirements are such that I need to show the interface of MSI so not showing the interface of msi is not an option. Can I programmatically call cancel button click of Innosetup. I tried to use CancelButtonClick event but it does not work. Also tried to use AfterInstal event, but could not rollback the installation. I can abruptly close the Innosetup exe but that does not rollback the changes. My goal is to clear the extracted files and also clear the registry of any entries if msi is not successfully installed.

 

Here is the script that I am using-

 

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);

begin 

   WizardForm.Close;

end;

 

 

 

procedure CurStepChanged(CurStep: TSetupStep);   

var CurPageID: Integer;  

var Cancel1 :Boolean;

var Confrm :Boolean;

begin

  if CurStep = ssPostInstall then

     begin

     try

      CurPageID := wpInstalling;

      Cancel1 :=true;

      Confrm :=false;

                CancelButtonClick(CurPageID, Cancel1,Confrm);

     except

             ShowExceptionMessage;

            end;

    

       end;

end;

 

[Run]  

  

  Filename: "{sys}\msiexec.exe";Parameters :"/i ""{app}\MyApp.msi"" /qb ARPSYSTEMCOMPONENT=1 ";  WorkingDir : {app};Check:IsFrameworkInstalled();

 

 

Rgds

 

Sent from Mail for Windows

 

Eivind Bakkestuen

unread,
Sep 15, 2023, 6:14:21 PM9/15/23
to inno...@googlegroups.com
ssPostInstall means exactly that; after installation. It is too late to cancel at this point. It needs to be cancelled at the ssInstall stage.

This means, you can't use the [Run] section to start the msi.

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/SJ0PR18MB4963A066A5965EF0BD5B7E67E2F6A%40SJ0PR18MB4963.namprd18.prod.outlook.com.

Wilenty do ut des

unread,
Sep 15, 2023, 6:21:14 PM9/15/23
to innosetup
Hello Charu Vasudev,
you can't cancel installation in the "ssPostInstall" stage, but you may execute uninstall which is not so good solution.
But, you can use the "PrepareToInstall" function to check "IsFrameworkInstalled()" and halt the installation, if need.

https://jrsoftware.org/ishelp/topic_scriptevents.htm#PrepareToInstall

Greetings,
Wilenty
Reply all
Reply to author
Forward
0 new messages