Warning dialog - Advanced Installer Community
holvaa
Posts: 7
Joined: Mon Sep 30, 2019 8:06 am

Warning dialog

Hello,

I've been working with AI for just a week now and this is actually the first time ever for me to write in a forum. So i hope I'm doing the right thing here.

Our Software is protected by WibyKey dongles and I'd like the installer at a certain point to proceed with the installation only if there is a valid WibuKey plugged.
What I did so far is:
1. I made sure that Wibu dirver is installed first
2. I wrote an inline script to read information from the WibuKey
3. I created a custom "User information" dialog in the "First Time Install" stage

in this "User Information" dialog I diaplay the information from the WibuKey if the script could successfully read it. In this case the installation should just proceed by clicking on NEXT.
Now, my problem is: If the script could not read any information and the user clicks on NEXT I'd like to have a little dialog warning the user that no WibuKey information have been found and prompt him to plug the WibuKey and click the "Read WibuyKey" button in the first dialog.
How could I do this?
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Warning dialog

Hello and welcome to Advanced Installer forums,
I've been working with AI for just a week now and this is actually the first time ever for me to write in a forum. So i hope I'm doing the right thing here.
Yes, you can ask your questions either here or over the e-mail at support at advancedinstaller dot com.

In what regards your question, here is how I see it achieved:

A brief description of what we are trying to achieve here:

If you go to "Dialogs" page, click on your "UserInformation" dialog and then select the "Next" button you can notice, under "Published Events", an event as it follows:

Event: Display a specific dialog
Argument: SomeDialog
Condition: AI_INSTALL (which translates to: this event will execute on an installation)


Basically, what we want to do here is extra conditioning that event, so that we will not allow the installation to continue until our condition is met. Additionally, here, we will add another event. This event will execute a custom action (in this case, our predefined MessageBox custom action), which will notify the user of what he needs to do in order to complete the installation.

Please find a more detailed explanation below:

- first of all, this:
in this "User Information" dialog I diaplay the information from the WibuKey if the script could successfully read it. In this case the installation should just proceed by clicking on NEXT.
Your script should contain the logic which decides if the information was correctly read from the WibuKey. To be fully honest with you, I am not so comfortable with how this security check works, but I would guess that one condition to retrieve the data is the file from where the data is retrieved should exist on the system. Based on that, we can have a condition as it follows:

Code: Select all

if (the file exists){
the data was correctly read
}

else {the data was not read}
- above, we said that we need to extra condition the "Display a specific dialog" event, so that the installation process will not proceed until our conditions are met. We can do this with the help of Windows Installer Properties. Properties are global variables used by Windows Installer during an installation.

Depending on what custom action you are using, here is how you can get & set properties from within a custom action:

"How to set an installer property using custom actions"

Now that we have explained this, here is how the logic in your script could look like:

Code: Select all

if (condition = true){
// the data was correctly read
Set a property to some value which indicates success
e.g. CONTINUE_INSTALLATION_PROPERTY=1
}

else {
// the data was not correctly read
Set a property to some value which indicates failure
e.g. CONTINUE_INSTALLATION_PROPERTY=0
}
- now, based on the above property, we can condition the dialog event. Here is how you can do so:

1. go to "Dialogs" page
2. select your dialog
3. click on the "Next" button
4. under "Published Events", double click on the "Display a specific dialog" event and, in the condition field, use a condition as it follows:

Code: Select all

CONTINUE_INSTALLATION_PROPERTY=1
Until the above property is set to "1" (the data was correctly read), we will not allow the installation to continue.

- now, we should move on with the message box custom action. In order to add such a custom action to your project, please go to "Custom Actions" page, select the "Display message box" custom action and click on the "Add custom action without sequence" button which is placed to the right side of the custom action's name.

- enter the details (i.e. the message, the title, etc.)

- now please go back to "Dialogs" page

- select your dialog and click on the "Next" button

- under the same "Published Events" tab, add another event, as it follows:

Event: Execute custom action
Argument: MessageBox
Condition: CONTINUE_INSTALLATION_PROPERTY=0


We will spawn this message box only when the data could not be read. In the "Published Events" tab, please schedule message box event before the display event. To do so, simply click on the message box event and press the "Up" button.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
holvaa
Posts: 7
Joined: Mon Sep 30, 2019 8:06 am

Re: Warning dialog

Hello Catalin,

thank you for that detailed description. The Custom action>MsgBox was exactly what I needed. However, my UserInformation dialog has no "display specific dialog" event. But I just added my property to the "Close the current dialog" event and it seems to do the job.


Thanks again for the quick response and best regards

Holger
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Warning dialog

You are always welcome, Holger.

I'm glad I could help.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”