PDA

View Full Version : VBScript Custom Action Return Values



RPatML
06-04-2004, 02:48 PM
Question 1:
We have an InstallShield X Basic MSI project. In it we have a few VBScript custom actions. If an error occurs in the VBScript function, we'd like the script to return an error code that indicates to start a rollback (this is for a execute sequence).

We look at help and found a Microsoft reference that shows:

Error Code Values returned by Values that appear Description
function calls in the Log
MsiExec.exe, and InstMsi.exe
ERROR_SUCCESS 0 1 Action completed successfully.
ERROR_INSTALL_FAILURE 1603 3 Fatal error.


So, for our code:

Option Explicit

'<<<< DO I DEFINE LIKE THIS >>>>
Const ERROR_SUCCESS = 0
Const ERROR_INSTALL_FAILURE = 1603

'<<<< OR LIKE THIS >>>>
Const ERROR_SUCCESS = 1
Const ERROR_INSTALL_FAILURE = 3


Function MyFunction()
On Error Resume Next

<code here>

If <error condition here> Then
MyFunction = ERROR_INSTALL_FAILURE
Exit Function
End If

MyFunction = ERROR_SUCCESS
End Function


Do we return 0 or 1 for success and 1603 or 3 for failure?


Question 2
Do these same return values work for immediate custom actions in the UI sequence (obviously not causing a rollback, but rather the installation to end)?

Thanks.

RobertDickau
06-04-2004, 02:58 PM
For VBScript actions, I believe either 0 or 1 indicates success, and 3 indicates failure. Please see, for example, this InstallShield newsletter tip: http://www.installshield.com/news/newsletter/0308-articles/msi.asp.

johnludlow
06-05-2004, 06:11 AM
There is also the Session.Message method, which can be used to display error messages, post to the log file, as well as ending the installation.