OpenPackage Method (packagePath, ignoreMachineState)

Microsoft Deployment Tools

Deployment Tools Foundation OpenPackage Method (packagePath, ignoreMachineState)
Deployment Tools Foundation NamespacesMicrosoft.Deployment.WindowsInstallerInstallerOpenPackage(String, Boolean)
Opens an installer package for use with functions that access the product database and install engine, returning an Session object.
Declaration Syntax
C# Visual Basic Visual C++
public static Session OpenPackage(
	string packagePath,
	bool ignoreMachineState
)
Public Shared Function OpenPackage ( _
	packagePath As String, _
	ignoreMachineState As Boolean _
) As Session
public:
static Session^ OpenPackage(
	String^ packagePath, 
	bool ignoreMachineState
)
Parameters
packagePath (String)
Path to the package
ignoreMachineState (Boolean)
Specifies whether or not the create a Session object that ignores the computer state and that is incapable of changing the current computer state. A value of false yields the normal behavior. A value of true creates a "safe" Session object that cannot change of the current machine state.
Return Value
A Session object allowing access to the product database and install engine
Remarks

Note that only one Session object can be opened by a single process. OpenPackage cannot be used in a custom action because the active installation is the only session allowed.

A "safe" Session object ignores the current computer state when opening the package and prevents changes to the current computer state.

The Session object should be Close()()()d after use. It is best that the handle be closed manually as soon as it is no longer needed, as leaving lots of unused handles open can degrade performance.

Win32 MSI APIs: MsiOpenPackage, MsiOpenPackageEx

Exceptions
Exception Condition
InstallerException The product could not be opened
InstallerException The installer configuration data is corrupt

Assembly: Microsoft.Deployment.WindowsInstaller (Module: Microsoft.Deployment.WindowsInstaller) Version: 3.0.0.0 (3.5.1623.0)