大网数据广告活动
安装更新与部署

Return Values of JScript and VBScript Custom Actions

· 52CE 我爱测

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.

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

If this VBScript were embedded in the Binary table of the installation package as MyCA.vbs, the CustomAction Table entry for the script would be the following:

Action Type Source Target
MyCustomAction 6 MyCA.vbs MyVBScriptCA

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。