we want the installer silent quit , (or pop our message) not through exception.
I easy to find the msdn about how to return value from custom action:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa371254(v=vs.85).aspx
Custom actions written in JScript or Visual Basic, Scripting Edition (VBScript) can call an optional function. These functions must return one of the values shown in the following table.
Return value | Value | Description |
---|---|---|
msiDoActionStatusNoAction | 0 | Action not executed. |
msiDoActionStatusSuccess | IDOK = 1 | Action completed successfully. |
msiDoActionStatusUserExit | IDCANCEL = 2 | Premature termination by user. |
msiDoActionStatusFailure | IDABORT = 3 | Unrecoverable error. Returned if there is an error during parsing or execution of the JScript or VBScript. |
msiDoActionStatusSuspend | IDRETRY = 4 | Suspended sequence to be resumed later. |
msiDoActionStatusFinished | IDIGNORE = 5 | Skip remaining actions. Not an error. |
Note that Windows Installer translates the return values from all actions when it writes the return value into the log file. For example, if the action return value appears as 1 (one) in the log file, this means that the action returned msiDoActionStatusSuccess. For more information about this translation see Logging of Action Return Values.
To return a value other than success from a script custom action, you must use a function target for the custom action. The target function is specified in the Target column of the CustomAction Table.
The following script example shows you how to return success or failure from a VBScript custom action.
Function MyVBScriptCA() If Session.Property("CustomErrorStatus") <> "0" Then 'return error MyVBScriptCA = 3 Exit Function End If ' return success MyVBScriptCA = 1 Exit Function End Function
Action | Type | Source | Target |
---|---|---|---|
MyCustomAction | 6 | MyCA.vbs | MyVBScriptCA |
Build date: 11/30/2012
We know the most important thing is :
To return a value other than success from a script custom action, you must use a function target for the custom action. The target function is specified in the Target column of the CustomAction Table.
The following script example shows you how to return success or failure from a VBScript custom action.
But how to set the target in customaction table ?
The vs2010 does not support us set the function name in target table directly.
We have to open msi file (use ora edit or supperora ) , find custom action table.
the problem is Action and Source when we open the custionaction table it is a numberstring create by vs2010. so , first we need from file table find the name. then we put the function name in customaction table target column .