Пример #1
0
 /// <summary>
 /// Gets a Windows Installer error message in the system default language.
 /// </summary>
 /// <param name="errorNumber">The error number.</param>
 /// <returns>The message string, or null if the error message is not found.</returns>
 /// <remarks><p>
 /// The returned string may have tokens such as [2] and [3] that are meant to be substituted
 /// with context-specific values.
 /// </p><p>
 /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always
 /// returned in English.
 /// </p></remarks>
 public static string GetErrorMessage(int errorNumber)
 {
     return(Installer.GetErrorMessage(errorNumber, null));
 }
        /// <summary>
        /// For each product listed by the patch package as eligible to receive the patch, ApplyPatch invokes
        /// an installation and sets the PATCH property to the path of the patch package.
        /// </summary>
        /// <param name="patchPackage">path to the patch package</param>
        /// <param name="installPackage">path to the product to be patched, if installType
        /// is set to <see cref="InstallType.NetworkImage"/></param>
        /// <param name="installType">type of installation to patch</param>
        /// <param name="commandLine">optional command line property settings</param>
        /// <exception cref="InstallerException">There was an error applying the patch</exception>
        /// <remarks><p>
        /// The <see cref="RebootRequired"/> and <see cref="RebootInitiated"/> properties should be
        /// tested after calling this method.
        /// </p><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiapplypatch.asp">MsiApplyPatch</a>
        /// </p></remarks>
        public static void ApplyPatch(string patchPackage, string installPackage, InstallType installType, string commandLine)
        {
            uint ret = NativeMethods.MsiApplyPatch(patchPackage, installPackage, (int)installType, commandLine);

            Installer.CheckInstallResult(ret);
        }
Пример #3
0
 /// <summary>
 /// Gets a formatted Windows Installer error message in the system default language.
 /// </summary>
 /// <param name="errorRecord">Error record containing the error number in the first field, and
 /// error-specific parameters in the other fields.</param>
 /// <returns>The message string, or null if the error message is not found.</returns>
 /// <remarks><p>
 /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always
 /// returned in English.
 /// </p></remarks>
 public static string GetErrorMessage(Record errorRecord)
 {
     return(Installer.GetErrorMessage(errorRecord, null));
 }
 /// <summary>
 /// For each product listed by the patch package as eligible to receive the patch, ApplyPatch invokes
 /// an installation and sets the PATCH property to the path of the patch package.
 /// </summary>
 /// <param name="patchPackage">path to the patch package</param>
 /// <param name="commandLine">optional command line property settings</param>
 /// <exception cref="InstallerException">There was an error applying the patch</exception>
 /// <remarks><p>
 /// The <see cref="RebootRequired"/> and <see cref="RebootInitiated"/> properties should be
 /// tested after calling this method.
 /// </p><p>
 /// Win32 MSI API:
 /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiapplypatch.asp">MsiApplyPatch</a>
 /// </p></remarks>
 public static void ApplyPatch(string patchPackage, string commandLine)
 {
     Installer.ApplyPatch(patchPackage, null, InstallType.Default, commandLine);
 }
        /// <summary>
        /// Configures the installed state for a product feature.
        /// </summary>
        /// <param name="productCode">Product code of the product to be configured.</param>
        /// <param name="feature">Specifies the feature ID for the feature to be configured.</param>
        /// <param name="installState">Specifies the installation state for the feature.</param>
        /// <exception cref="InstallerException">There was an error configuring the feature</exception>
        /// <remarks><p>
        /// The <see cref="RebootRequired"/> and <see cref="RebootInitiated"/> properties should be
        /// tested after calling this method.
        /// </p><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiconfigurefeature.asp">MsiConfigureFeature</a>
        /// </p></remarks>
        public static void ConfigureFeature(string productCode, string feature, InstallState installState)
        {
            uint ret = NativeMethods.MsiConfigureFeature(productCode, feature, (int)installState);

            Installer.CheckInstallResult(ret);
        }
        /// <summary>
        /// Installs or uninstalls a product.
        /// </summary>
        /// <param name="productCode">Product code of the product to be configured.</param>
        /// <param name="installLevel">Specifies the default installation configuration of the
        /// product. The <paramref name="installLevel"/> parameter is ignored and all features
        /// are installed if the <paramref name="installState"/> parameter is set to any other
        /// value than <see cref="InstallState.Default"/>. This parameter must be either 0
        /// (install using authored feature levels), 65535 (install all features), or a value
        /// between 0 and 65535 to install a subset of available features.																																											   </param>
        /// <param name="installState">Specifies the installation state for the product.</param>
        /// <param name="commandLine">Specifies the command line property settings. This should
        /// be a list of the format Property=Setting Property=Setting.</param>
        /// <exception cref="InstallerException">There was an error configuring the product</exception>
        /// <remarks><p>
        /// This method displays the user interface with the current settings and
        /// log mode. You can change user interface settings with the <see cref="SetInternalUI(InstallUIOptions)"/>
        /// and <see cref="SetExternalUI(ExternalUIHandler,InstallLogModes)"/> functions. You can set the log mode with the
        /// <see cref="EnableLog(InstallLogModes,string)"/> function.
        /// </p><p>
        /// The <see cref="RebootRequired"/> and <see cref="RebootInitiated"/> properties should be
        /// tested after calling this method.
        /// </p><p>
        /// Win32 MSI APIs:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiconfigureproduct.asp">MsiConfigureProduct</a>,
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiconfigureproductex.asp">MsiConfigureProductEx</a>
        /// </p></remarks>
        public static void ConfigureProduct(string productCode, int installLevel, InstallState installState, string commandLine)
        {
            uint ret = NativeMethods.MsiConfigureProductEx(productCode, installLevel, (int)installState, commandLine);

            Installer.CheckInstallResult(ret);
        }
        /// <summary>
        /// Opens an installer package and initializes an install session.
        /// </summary>
        /// <param name="packagePath">path to the patch package</param>
        /// <param name="commandLine">command line property settings</param>
        /// <exception cref="InstallerException">There was an error installing the product</exception>
        /// <remarks><p>
        /// To completely remove a product, set REMOVE=ALL in <paramRef name="commandLine"/>.
        /// </p><p>
        /// This method displays the user interface with the current settings and
        /// log mode. You can change user interface settings with the <see cref="SetInternalUI(InstallUIOptions)"/>
        /// and <see cref="SetExternalUI(ExternalUIHandler,InstallLogModes)"/> functions. You can set the log mode with the
        /// <see cref="EnableLog(InstallLogModes,string)"/> function.
        /// </p><p>
        /// The <see cref="RebootRequired"/> and <see cref="RebootInitiated"/> properties should be
        /// tested after calling this method.
        /// </p><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiinstallproduct.asp">MsiInstallProduct</a>
        /// </p></remarks>
        public static void InstallProduct(string packagePath, string commandLine)
        {
            uint ret = NativeMethods.MsiInstallProduct(packagePath, commandLine);

            Installer.CheckInstallResult(ret);
        }
 /// <summary>
 /// Enables logging of the selected message type for all subsequent install sessions in
 /// the current process space.
 /// </summary>
 /// <param name="logModes">One or more mode flags specifying the type of messages to log</param>
 /// <param name="logFile">Full path to the log file.  A null path disables logging,
 /// in which case the logModes paraneter is ignored.</param>
 /// <exception cref="ArgumentException">an invalid log mode was specified</exception>
 /// <remarks>This method takes effect on any new installation processes.  Calling this
 /// method from within a custom action will not start logging for that installation.</remarks>
 public static void EnableLog(InstallLogModes logModes, string logFile)
 {
     Installer.EnableLog(logModes, logFile, false, true);
 }