cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Diablo_m
Level 4

Message box from custom action

Hi.

I need to show a message box with yes/no buttons and some text from custom action. My installation is MSI project and I wanted this message box to be shown from VB script. I googled for the samples but found nothing.

So is it possible to show standart Windows message box from VB code or some other custom action? Please give me a sample code, 'cause I'm nube in VB 😞
Labels (1)
0 Kudos
(4) Replies
esiemiat
Level 9

It is possible to use the MsgBox command in a VBScript CA but you have to account for the UILevel when showing the message box so as to not show it during a silent installation.

I use the Session.Message method to show messages as it handles the UILevel for you. The following code shows an informative message either to the log or screen depending on the UIlevel. Other codes can be used instead of &H03000000 to show an error or warning message.


Set hMsgRecord = Installer.CreateRecord(0)
hMsgRecord.StringData(0) = "Test message"
Session.Message &H03000000, hMsgRecord
Set hMsgRecord = nothing
0 Kudos
Diablo_m
Level 4

esiemiat wrote:
It is possible to use the MsgBox command in a VBScript CA but you have to account for the UILevel when showing the message box so as to not show it during a silent installation.

I use the Session.Message method to show messages as it handles the UILevel for you. The following code shows an informative message either to the log or screen depending on the UIlevel. Other codes can be used instead of &H03000000 to show an error or warning message.


Set hMsgRecord = Installer.CreateRecord(0)
hMsgRecord.StringData(0) = "Test message"
Session.Message &H03000000, hMsgRecord
Set hMsgRecord = nothing


Thank you for reply. This code is good, but it does not solve one of my problems - the message should be localizable. How to get the message text from the resources?
0 Kudos
esiemiat
Level 9

To localize the message you will either need to use the Error table or a localized property.

More information about both options can be found in the help library. However, I included a sample from one of my installs that uses the error table.

[CODE]
Set hMsgRecord = Installer.CreateRecord(2)
hMsgRecord.IntegerData(1) = 25002 'Error message number in error table.
hMsgRecord.StringData(2) = sNetworkDir ' Replaces [2] in error message.
Session.Message msiMessageTypeError, hMsgRecord
Set hMsgRecord = nothing
[/CODE]

Here is the localizable message listed in the error table. Anything listed in {{}} will only be printed to the log file.

The specified Pages network folder is not valid.{{Value='[2]'}}
0 Kudos
Diablo_m
Level 4

Thank you, you helped me much!
0 Kudos