asia.shafran
Posts: 9
Joined: Wed Jan 18, 2017 12:53 pm

Show Error message from Custom Action

Hi

In my installer I am running some custom actions(powershell script files) .
I want that if some custom action fail, it would present an error message to the user with error details
For example if the script is trying to delete some folder that can't be deleted.. The user will see some error message saying this folder already in use

I don't want do it threw the powershell script because in the future I want to stop using this scripts.

I saw this similar issue http://www.advancedinstaller.com/forums ... hp?t=29112, but couldnt understand the solution
How does it work? How does I make this error dialog to appear if error occured and how do i present the needed message?

thanks
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Show Error message from Custom Action

Hello,

A solution would be to generate an error message box from the script itself.
You could use the following code:

Code: Select all

[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('Error log')
Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
asia.shafran
Posts: 9
Joined: Wed Jan 18, 2017 12:53 pm

Re: Show Error message from Custom Action

Sorin wrote:Hello,

A solution would be to generate an error message box from the script itself.
You could use the following code:

Code: Select all

[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show('Error log')
Best regards,
Sorin
As I said, this is what I'm trying to avoid. I don't want to pop up message box inside my powershell script.. Is there any other solution? using fatal dialog maybe?
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Show Error message from Custom Action

Hello,

A possible solution would be to set an installer property in your PowerShell script, named for example "ERROR". This property could contain an error message. Please take a look on this article : How to set an installer property using custom actions

You could use a Display Message Box / Display Error message custom action configured in the following way:

Code: Select all

Message:[ERROR]
Condition: ERROR<>""
This method has the disadvantage that it could be used only for "Immediately" PowerShell custom actions, as Installer Properties are available only during the immediate stage of the install execution process.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”