msi

package
v0.72.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package msi contains helper functions to work with msi packages.

The package provides automatic retry functionality for MSI operations using exponential backoff to handle transient errors, particularly exit code 1618 (ERROR_INSTALL_ALREADY_RUNNING) which occurs when another MSI installation is in progress.

Package msi contains helper functions to work with msi packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProductFeatures added in v0.72.0

func GetProductFeatures(productCode []uint16) ([]string, error)

GetProductFeatures enumberates all features for a given product code and returns them as a list of strings.

func IsProductInstalled

func IsProductInstalled(productName string) bool

IsProductInstalled returns true if the given productName is installed

func RemoveProduct

func RemoveProduct(ctx context.Context, productName string, opts ...MsiexecOption) error

RemoveProduct uses the registry to try and find a product and use msiexec to remove it. It is different from msiexec in that it uses the registry and not the stable/experiment path on disk to uninstall the product. This is needed because in certain circumstances the installer database stored in the stable/experiment paths does not reflect the installed version, and using those installers can lead to undefined behavior (either failure to uninstall, or weird bugs from uninstalling a product with an installer from a different version).

func SetSourceList added in v0.72.0

func SetSourceList(productName string, sourcePath string, packageName string) error

SetSourceList sets the source list for a given product name

Types

type Msiexec

type Msiexec struct {
	// contains filtered or unexported fields
}

Msiexec is a type wrapping msiexec

func Cmd

func Cmd(options ...MsiexecOption) (*Msiexec, error)

Cmd creates a new Msiexec wrapper around cmd.Exec that will call msiexec

func (*Msiexec) Run

func (m *Msiexec) Run(ctx context.Context) error

Run runs msiexec synchronously with retry logic

type MsiexecError added in v0.70.0

type MsiexecError struct {

	// LogFileBytes contains the processed log file content with error-relevant information
	// see openAndProcessLogFile for more details
	ProcessedLog string
	// contains filtered or unexported fields
}

MsiexecError provides the processed log file content and the underlying error.

func (*MsiexecError) Error added in v0.70.0

func (e *MsiexecError) Error() string

func (*MsiexecError) Unwrap added in v0.70.0

func (e *MsiexecError) Unwrap() error

type MsiexecOption

type MsiexecOption func(*msiexecArgs) error

MsiexecOption is an option type for creating msiexec command lines

func AdministrativeInstall

func AdministrativeInstall() MsiexecOption

AdministrativeInstall specifies that msiexec will be invoked to extract the product

func HideControlPanelEntry

func HideControlPanelEntry() MsiexecOption

HideControlPanelEntry passes a flag to msiexec so that the installed program does not show in the Control Panel "Add/Remove Software"

func Install

func Install() MsiexecOption

Install specifies that msiexec will be invoked to install a product

func Uninstall

func Uninstall() MsiexecOption

Uninstall specifies that msiexec will be invoked to uninstall a product

func WithAdditionalArgs

func WithAdditionalArgs(additionalArgs []string) MsiexecOption

WithAdditionalArgs specifies raw additional arguments for msiexec, e.g. []string{"PROP=VALUE", "WIXUI_DONTVALIDATEPATH=1"} These are appended as-is without additional quoting. Use WithProperties for MSI properties to ensure they are properly quoted.

func WithDdAgentUserName

func WithDdAgentUserName(ddagentUserName string) MsiexecOption

WithDdAgentUserName specifies the DDAGENTUSER_NAME to use

func WithDdAgentUserPassword added in v0.66.0

func WithDdAgentUserPassword(ddagentUserPassword string) MsiexecOption

WithDdAgentUserPassword specifies the DDAGENTUSER_PASSWORD to use

func WithLogFile

func WithLogFile(logFile string) MsiexecOption

WithLogFile specifies the log file for msiexec

func WithMsi

func WithMsi(target string) MsiexecOption

WithMsi specifies the MSI target for msiexec

func WithMsiFromPackagePath

func WithMsiFromPackagePath(target, product string) MsiexecOption

WithMsiFromPackagePath finds an MSI from the packages folder

func WithProduct

func WithProduct(productName string) MsiexecOption

WithProduct specifies the product name to target for msiexec

func WithProperties added in v0.70.0

func WithProperties(props map[string]string) MsiexecOption

WithProperties specifies additional MSI properties as Key=Value entries. In the final command line, values are always quoted and any embedded quotes are escaped by doubling them. Properties are appended in sorted key order to ensure deterministic command line construction.

type Product

type Product struct {
	// Code is the software product code
	Code string
	// UninstallString is the string that can be executed to uninstall the software. May be empty.
	UninstallString string
	// Features is a list of features installed by the product.
	Features []string
}

Product represents a software from the Windows Registry

func FindAllProductCodes added in v0.72.0

func FindAllProductCodes(productName string) ([]Product, error)

FindAllProductCodes looks for all products with the given productName using the Windows Installer API It enumerates through all products and checks if the product name matches the given productName.

func FindProductCode

func FindProductCode(productName string) (*Product, error)

FindProductCode finds the first product with the specified display name

func FindUninstallProductCodes added in v0.72.0

func FindUninstallProductCodes(productName string) ([]*Product, error)

FindUninstallProductCodes looks for the productName in the registry and returns information about it

type TextRange

type TextRange struct {
	// contains filtered or unexported fields
}

TextRange is a simple struct to represent a range of text in a file.

func Combine

func Combine(input []byte, processors ...logFileProcessor) []TextRange

Combine processes input using multiple logFileProcessors and merges their output ranges.

func FindAllIndexWithContext

func FindAllIndexWithContext(r *regexp.Regexp, input []byte, contextBefore, contextAfter int) []TextRange

FindAllIndexWithContext is similar to FindAllIndex but expands the matched range for a number of lines before and after the TextRange (called contextBefore and contextAfter).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL