Installer.LastErrorRecord Method

Windows Installer

Installer.LastErrorRecord Method

The LastErrorRecord method of the Installer object returns a Record object that contains error parameters for the most recent error from the function that produced the error record.

Syntax

Script
LastErrorRecord()

Parameters

This method has no parameters.

Return Value

This method does not return a value.

Remarks

The Record object is reset after the execution of this function of any function that generates an error record.

Only the following designated functions generate an error record:

The following sample in VBScript uses a call to OpenDatabase to show how to obtain extended error information from one of the methods or properties that support the LastErrorRecord method. The sample constructs an error message when the OpenDatabase method fails. The Err object is used to determine whether an error was encountered.

Const msiOpenDatabaseModeReadOnly     = 0

On Error Resume Next ' defer error handling

Dim installer
Set installer = CreateObject("WindowsInstaller.Installer")

' attempt to open the non-existent MSI database
Dim database
Set database = installer.OpenDatabase("c:\nonexistent.msi", msiOpenDatabaseModeReadOnly)

' test for error
If Err.Number <> 0 Then
	Dim message, errorRec
	message = Err.Source & " " & Hex(Err.Number) & ": " & Err.Description
	If Not installer Is Nothing Then
		' try to obtain extended error info
		Set errorRec = installer.LastErrorRecord
		If Not errorRec Is Nothing Then message = message & vbNewLine & errorRec.FormatText
	End If

	MsgBox message

	' PLACE ADDITIONAL SCRIPTING CODE HERE TO LOG AND/OR DISPLAY THE MESSAGE AND
	' DETERMINE WHETHER TO CONTINUE PROCESSING ANYTHING ELSE
End If

Requirements

VersionWindows Installer 5.0 on Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003, Windows XP, and Windows 2000
DLLMsi.dll
IIDIID_IInstaller is defined as 000C1090-0000-0000-C000-000000000046

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.