We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Clutch
Posts: 12
Joined: Sat Oct 20, 2018 4:23 am

Remain on Dialog after Error Message

I have a custom Dialog (SelVer), where the User will select (via checkbox), which version of an application they already have installed. Using a custom PowerShell script I am able to verify if this application is truly installed:


If ((AI_GetMsiProperty CHECKBOX_APP_PROP -eq "CheckBox") -and (AI_GetMsiProperty APP_INSTALL_PATH -eq ""))
{
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('The APP was not found. Close this window and select an App version that is currently installed.','APP Validation Error!','OK','ERROR')
}


This works as written, however when the User clicks on the ‘OK’ button of the Windows.Forms.MessageBox I want them to remain on the SelVer Dialog where they were selecting the APP version. Currently, it sequentially moves on to the next Dialog. I need to have them remain on the current Dialog so they cannot proceed with the install until they select the proper App version or press CANCEL.

So my question is does PowerShell have code to manipulate the ‘OK’ button to go to a specific Dialog much like Advanced Installer has?

If this is not possible, my only other thought was to create a custom Dialog which essentially would work like an ErrDlg. That way I may be able to have it revert/stay on the SelVer Dialog using an Event. But I am not having luck in getting the conditions to work to have the custom Dialog appear. I am not even sure if I can use a Dialog in this manner?

In my custom SelVer Dialog for the NEXT button, I have under the Published Events tab I created a new Event with the Argument choosing SpawnWaitDialog and using the following Condition below:

CHECKBOX_P3D_PROP = "CheckBox" AND APP_INSTALL_PATH = ""

But no luck in having the message window to appear. Any help would be most appreciated.

Oh, another quick question... can a Dialog be a Property (thinking powershell code here).

Happy Holidays
Marcus
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Remain on Dialog after Error Message

Hello Marcus,

This is probably happening because, on your custom dialog, you have an event which looks like this:

Code: Select all

Event: Display a specific dialog
Argument: <the next dialog that comes in sequence"
Condition: AI_INSTALL
The AI_INSTALL condition, as its name suggests, will make your custom action to always execute (if you are doing an install). Here is how I would proceed in your scenario:

I would use a two values property to condition the "Display a specific dialog" event. This can all be done from within your script. Here is how I think your script would look like after the changes:

Code: Select all

If ((AI_GetMsiProperty CHECKBOX_APP_PROP -eq "CheckBox") -and (AI_GetMsiProperty APP_INSTALL_PATH -eq ""))
{
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('The APP was not found. Close this window and select an App version that is currently installed.','APP Validation Error!','OK','ERROR')
AI_SetMsiProperty MY_PROP true
}
else {AI_SetMsiProperty MY_PROP false}
After doing the above changes to your script, you can condition the "Display a specific dialog" event as it follows:

Code: Select all

AI_INSTALL AND MY_PROP <> "true"
Explanation: The above condition can be translated to the following: Execute the event when an install is happening and when "MY_PROP" property is different than "true". As you can see, we set the property inside the if statement and it will be set only if your criteria is met (the checkbox state is "CheckBox" and the "APP_INSTALL_PATH" equals ""). If they select the correct version of your application, the script will ignore the if statement and will go over to the else statement, where "MY_PROP" property is set to "false" (here you could really use any value which is different than "true", but for the sake of simplicity and clarity, I have used "false").
Oh, another quick question... can a Dialog be a Property (thinking powershell code here).
Unfortunately, you can not use a dialog as a property. A dialog is, in fact, a Windows Installer action.

Please let me know if the above information is helpful.

Happy Holidays to you, too!

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Clutch
Posts: 12
Joined: Sat Oct 20, 2018 4:23 am

Re: Remain on Dialog after Error Message

Thank you for such a quick reply. It works like a charm except for an issue I did not explain clearly in my previous thread. You see, a User has six app versions to choose from (via checkboxes). What happens with your edits applied is only the last App version (in this case App3), works correctly. If I select for App1 or App2 and they are not installed, the installer will still move on to the next dialog.

And to add a little more fun the User may have more than one version of an app installed so they could have more than one type "checked". So my code looks like the following.

As you can see the code is basically repeated three times to represent three app versions. The total is six but you get the idea.

Code: Select all

If ((AI_GetMsiProperty CHECKBOX_APP1_PROP -eq "CheckBox") -and (AI_GetMsiProperty APP1_INSTALL_PATH -eq ""))
{
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('The APP1 was not found. Close this window and select an App version that is currently installed.','APP Validation Error!','OK','ERROR')
AI_SetMsiProperty MY_PROP true
}
else {AI_SetMsiProperty MY_PROP false}

If ((AI_GetMsiProperty CHECKBOX_APP2_PROP -eq "CheckBox") -and (AI_GetMsiProperty APP2_INSTALL_PATH -eq ""))
{
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('The APP2 was not found. Close this window and select an App version that is currently installed.','APP2 Validation Error!','OK','ERROR')
AI_SetMsiProperty MY_PROP true
}
else {AI_SetMsiProperty MY_PROP false}

If ((AI_GetMsiProperty CHECKBOX_APP3_PROP -eq "CheckBox") -and (AI_GetMsiProperty APP3_INSTALL_PATH -eq ""))
{
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('The APP3 was not found. Close this window and select an App version that is currently installed.','APP3 Validation Error!','OK','ERROR')
AI_SetMsiProperty MY_PROP true
}
else {AI_SetMsiProperty MY_PROP false}
I suspect it is the order in which the code is written where App3 checking will override any App1 or App2 settings? I have tried working with 'elseIf' and '-or' but my PowerShell skills are not so great. :oops:
Clutch
Posts: 12
Joined: Sat Oct 20, 2018 4:23 am

Re: Remain on Dialog after Error Message

Well after another look at this it appears the 'elseif' condition is working. Thought I tested with this or enough testing but it appears to be working for me now. Maybe it was just a type. So I would now say all is good.

Best of the New Year for you and yours :D
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Remain on Dialog after Error Message

You are always welcome, Marcus.

I am glad I could help and I am glad you got this working.

All the best in the new year for you as well,
Catalin
:D
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”