Installation and Uninstallation discussion
Monday, September 20, 2010
Install the product/files and product on machine
Using windows MSI we can deploy our product solution in a very easy way. For creating windows installer based deployment, we can use various kinds of the IDE or tools. Visual Studio is one of the most known tool to create windows installation solution.
By using windows installer you can
1. Copy files on any number of different locations depending on requirements
2. Customize registry keys depending on the requirements
3. Create windows services on the machine.
4. Customize any kind of windows behaviour.
In Visual Studio, to create deployment solution you need to add a new project that can be created by using predefined template under New Projects>Other Project Types>Setup and Deployment>Visual Studio Installer [In Visual Studio 2010]. It also have a template with InstallShield too.
So, now you can plan your deployment solution by using windows installer while you need to deploy specific files or to create specific behavior on the client machine for your product deployed.
Tuesday, July 1, 2008
Friday, June 27, 2008
Windows Installer Error Codes
From Link : http://msdn.microsoft.com/en-us/library/aa368542.aspx
error codes ERROR_SUCCESS, ERROR_SUCCESS_REBOOT_INITIATED, and ERROR_SUCCESS_REBOOT_REQUIRED are indicative of success. If ERROR_SUCCESS_REBOOT_REQUIRED is returned, the installation completed successfully but a reboot is required to complete the installation operation.
See Windows Installer Error Messages for errors returned by the Windows Installer.
Error code | Value | Description |
---|---|---|
ERROR_SUCCESS | 0 | The action completed successfully. |
ERROR_INVALID_DATA | 13 | The data is invalid. |
ERROR_INVALID_PARAMETER | 87 | One of the parameters was invalid. |
ERROR_CALL_NOT_IMPLEMENTED | 120 | This value is returned when a custom action attempts to call a function that cannot be called from custom actions. The function returns the value ERROR_CALL_NOT_IMPLEMENTED. Available beginning with Windows Installer version 3.0. |
ERROR_APPHELP_BLOCK | 1259 | If Windows Installer determines a product may be incompatible with the current operating system, it displays a dialog box informing the user and asking whether to try to install anyway. This error code is returned if the user chooses not to try the installation. |
ERROR_INSTALL_SERVICE_FAILURE | 1601 | The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered. |
ERROR_INSTALL_USEREXIT | 1602 | The user cancels installation. |
ERROR_INSTALL_FAILURE | 1603 | A fatal error occurred during installation. |
ERROR_INSTALL_SUSPEND | 1604 | Installation suspended, incomplete. |
ERROR_UNKNOWN_PRODUCT | 1605 | This action is only valid for products that are currently installed. |
ERROR_UNKNOWN_FEATURE | 1606 | The feature identifier is not registered. |
ERROR_UNKNOWN_COMPONENT | 1607 | The component identifier is not registered. |
ERROR_UNKNOWN_PROPERTY | 1608 | This is an unknown property. |
ERROR_INVALID_HANDLE_STATE | 1609 | The handle is in an invalid state. |
ERROR_BAD_CONFIGURATION | 1610 | The configuration data for this product is corrupt. Contact your support personnel. |
ERROR_INDEX_ABSENT | 1611 | The component qualifier not present. |
ERROR_INSTALL_SOURCE_ABSENT | 1612 | The installation source for this product is not available. Verify that the source exists and that you can access it. |
ERROR_INSTALL_PACKAGE_VERSION | 1613 | This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service. |
ERROR_PRODUCT_UNINSTALLED | 1614 | The product is uninstalled. |
ERROR_BAD_QUERY_SYNTAX | 1615 | The SQL query syntax is invalid or unsupported. |
ERROR_INVALID_FIELD | 1616 | The record field does not exist. |
ERROR_INSTALL_ALREADY_RUNNING | 1618 | Another installation is already in progress. Complete that installation before proceeding with this install. For information about the mutex, see _MSIExecute Mutex. |
ERROR_INSTALL_PACKAGE_OPEN_FAILED | 1619 | This installation package could not be opened. Verify that the package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer package. |
ERROR_INSTALL_PACKAGE_INVALID | 1620 | This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package. |
ERROR_INSTALL_UI_FAILURE | 1621 | There was an error starting the Windows Installer service user interface. Contact your support personnel. |
ERROR_INSTALL_LOG_FAILURE | 1622 | There was an error opening installation log file. Verify that the specified log file location exists and is writable. |
ERROR_INSTALL_LANGUAGE_UNSUPPORTED | 1623 | This language of this installation package is not supported by your system. |
ERROR_INSTALL_TRANSFORM_FAILURE | 1624 | There was an error applying transforms. Verify that the specified transform paths are valid. |
ERROR_INSTALL_PACKAGE_REJECTED | 1625 | This installation is forbidden by system policy. Contact your system administrator. |
ERROR_FUNCTION_NOT_CALLED | 1626 | The function could not be executed. |
ERROR_FUNCTION_FAILED | 1627 | The function failed during execution. |
ERROR_INVALID_TABLE | 1628 | An invalid or unknown table was specified. |
ERROR_DATATYPE_MISMATCH | 1629 | The data supplied is the wrong type. |
ERROR_UNSUPPORTED_TYPE | 1630 | Data of this type is not supported. |
ERROR_CREATE_FAILED | 1631 | The Windows Installer service failed to start. Contact your support personnel. |
ERROR_INSTALL_TEMP_UNWRITABLE | 1632 | The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it. |
ERROR_INSTALL_PLATFORM_UNSUPPORTED | 1633 | This installation package is not supported on this platform. Contact your application vendor. |
ERROR_INSTALL_NOTUSED | 1634 | Component is not used on this machine. |
ERROR_PATCH_PACKAGE_OPEN_FAILED | 1635 | This patch package could not be opened. Verify that the patch package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer patch package. |
ERROR_PATCH_PACKAGE_INVALID | 1636 | This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package. |
ERROR_PATCH_PACKAGE_UNSUPPORTED | 1637 | This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service. |
ERROR_PRODUCT_VERSION | 1638 | Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs in Control Panel. |
ERROR_INVALID_COMMAND_LINE | 1639 | Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help. |
ERROR_INSTALL_REMOTE_DISALLOWED | 1640 | Installation from a Terminal Server client session is not permitted for the current user. |
ERROR_SUCCESS_REBOOT_INITIATED | 1641 | The installer has initiated a restart. This message is indicative of a success. |
ERROR_PATCH_TARGET_NOT_FOUND | 1642 | The installer cannot install the upgrade patch because the program being upgraded may be missing or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch. |
ERROR_PATCH_PACKAGE_REJECTED | 1643 | The patch package is not permitted by system policy. |
ERROR_INSTALL_TRANSFORM_REJECTED | 1644 | One or more customizations are not permitted by system policy. |
ERROR_INSTALL_REMOTE_PROHIBITED | 1645 | Windows Installer does not permit installation from a Remote Desktop Connection. |
ERROR_PATCH_REMOVAL_UNSUPPORTED | 1646 | The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0. |
ERROR_UNKNOWN_PATCH | 1647 | The patch is not applied to this product. Available beginning with Windows Installer version 3.0. |
ERROR_PATCH_NO_SEQUENCE | 1648 | No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0. |
ERROR_PATCH_REMOVAL_DISALLOWED | 1649 | Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0. |
ERROR_INVALID_PATCH_XML | 1650 | The XML patch data is invalid. Available beginning with Windows Installer version 3.0. |
ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT | 1651 | Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state. Available beginning with Windows Installer version 3.0. |
ERROR_SUCCESS_REBOOT_REQUIRED | 3010 | A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run. |
Sunday, June 15, 2008
Change the full path of the product installation
Note: I've searched the various links to get information at one place. I've not checked the contents for validation. So I'm not responsible for any issue found related to the contents specified in the blog. Please use contents at own risk.
The api directory function of Msi - MsiSetTargetPath can be used to set the target path of the product to be installed. The complete syntax declaration of the api is given below:
MsiSetTargetPath:
Declare Function MsiSetTargetPath lib "MSI" (ByRef hInstall As MSIHANDLE, ByVal szFolder As String, ByVal szFolderPath As String) As LongThis function Sets the full target path for a directory listed in the Directory table.
Parameters
- hInstall [in] Handle to the installation provided to a DLL custom action or obtained
- through MsiOpenPackage, MsiOpenPackageEx, or
- MsiOpenProduct.
- szFolder [in] Specifies the folder identifier. This is a primary key in the Directory table.
- szFolderPath [in] Specifies the full path for the folder, ending in a directory separator.
Return Value
The MsiSetTargetPath function returns the following values:
- ERROR_DIRECTORY The directory specified was not found in the Directory table.
- ERROR_INVALID_HANDLE An invalid or inactive handle was supplied.
- ERROR_INVALID_PARAMETER An invalid parameter was passed to the function.
- ERROR_SUCCESS The function succeeded.
The Directory table specifies the directory layout for the product. Each row of the table indicates a directory both at the source and the target.
The Directory table has the following columns.
Column | Type | Key | Nullable |
---|---|---|---|
Directory | Identifier | Y | N |
Directory_Parent | Identifier | N | Y |
DefaultDir | DefaultDir | N | N |
Before using MsiSetTargetPath function, check the product state to ensure that nothing of the product was installed yet.
The installer sets the ProductState property to the installation state for the product at initialization. This property is set to one of the following INSTALLSTATE data types returned by MsiQueryProductState.
use the function MsiQueryProductState for this purpose.
MsiQueryProductState Function
Declare Function MsiQueryProductState lib "MSI" (ByVal szProduct As String) As INSTALLSTATE
Parameters
- szProduct [in] Specifies the product code that identifies the product to be queried.
Return Value
Value | Meaning |
---|---|
INSTALLSTATE_ABSENT | The product is installed for a different user. |
INSTALLSTATE_ADVERTISED | The product is advertised but not installed. |
INSTALLSTATE_DEFAULT | The product is installed for the current user. |
INSTALLSTATE_INVALIDARG | An invalid parameter was passed to the function. |
INSTALLSTATE_UNKNOWN | The product is neither advertised or installed. |
MsiOpenProduct
The MsiOpenProduct function opens a product for use with the functions that access the product database. The MsiCloseHandle function must be called with the handle when the handle is no longer needed.
Declare Function MsiOpenProduct lib "MSI" (ByVal szProduct As String, ByRef hProduct As MSIHANDLE) As Long
Parameters
- szProduct [in] Specifies the product code of the product to be opened.
- hProduct [out] Pointer to a variable that receives the product handle.
Return Value
Value | Meaning |
---|---|
ERROR_BAD_CONFIGURATION | The configuration information is corrupt. |
ERROR_INSTALL_FAILURE | The product could not be opened. |
ERROR_INSTALL_SOURCE_ABSENT | The source was unavailable. |
ERROR_INVALID_PARAMETER | An invalid parameter was passed to the function. |
ERROR_SUCCESS | The function completed successfully. |
ERROR_UNKNOWN_PRODUCT | The product code was unrecognized. |
MsiCloseHandle
Closes a database, view, or record handle.
Declare Function MsiCloseHandle lib "MSI" (ByRef hAny As MSIHANDLE) As Long
- hAny [in] Specifies any open installation handle.
Return Value
Value | Meaning |
---|---|
ERROR_INVALID_HANDLE | An invalid handle was passed to the function. |
ERROR_SUCCESS | The function succeeded. |
Related Studies:
1. Managed Applications
2. Microsoft Installer: MSI
3. msiblogger
Friday, June 13, 2008
MsiExec.exe Command-Line Parameters
Note: I've searched the various links to get information at one place. I've not checked the help for validation. So I'm not responsible for any issue found related to the contents specified in the blog. Please use contents at own risk.
The table below provides a detailed description of MsiExec.exe command line parameters.
Windows Installer API Functions
Most Windows Installer API functions take a handle to the currently running database as an argument. For an InstallScript custom action, the database handle is the HWND argument passed to the custom action. In an event-handler function, you can use the global variable ISMSI_HANDLE, which stores the handle to the running .msi database.
Declaration about the functions is :Declare Function MsiApplyPatch lib "MSI" (ByVal szPatchPackage As String, ByVal szInstallPackage As String, ByVal eInstallType As Struct_MembersOf_INSTALLTYPE, ByVal szCommandLine As String) As Long | ||
Windows Installer API Functions by CategoryTo quickly navigate to a function category, click on one of the options below.
| ||
MSI Property and Mode Functions | ||
MsiSetProperty Sets the value of a Windows Installer property. Creates the property if it does not exist. (For an example, see Get or Set a Property.) MsiGetProductInfo Returns product information for published and installed products. MsiGetProperty Gets the value of a Windows Installer property. Returns a null string ("") if the property does not exist. MsiGetLanguage Returns the numeric language ID for the running installation. MsiGetMode Returns an internal boolean Installer state. MsiSetMode Sets an internal boolean Installer state. Feature and Component Functions MsiGetFeatureState Gets the installation state and action state of a feature. MsiSetFeatureState Sets the installation state of a feature. MsiSetFeatureAttributes:Sets the attributes for a feature. MsiGetFeatureValidStates:Returns a set of bit flags representing the valid installation states of a feature. MsiGetComponentState Gets the installation state and action state of a component. MsiSetComponentState Sets the installation state of a component. MsiGetFeatureCost Returns the disk cost of a feature (in units of 512 bytes), and optionally its parent and child features. MsiSetInstallLevel Sets the install level for the entire product. Directory Functions MsiGetSourcePath Returns the full source path for a directory listed in the Directory table. (The Directory table is exposed in the Direct Editor.) MsiGetTargetPath Returns the full target path for a directory listed in the Directory table. MsiSetTargetPath Sets the full target path for a directory listed in the Directory table. MsiVerifyDiskSpace Verifies if sufficient disk space exists for the current installation. Database Functions With the exception of MsiGetActiveDatabase, the first HWND argument in most of these functions is a handle to a specific database view or record. MsiEvaluateCondition Evaluates a conditional expression that contains property names and values. MsiGetActiveDatabase Obtains a handle to the running .msi database, which you can use to open database views. MsiDatabaseApplyTransform: Applies a transform to a database. A transform is a way of recording changes to a database without altering the original database. MsiDatabaseExport Exports an installer table from an open database to a text archive file. MsiDatabaseGenerateTransform Generates a transform file of differences between two databases. A transform is a way of recording changes to a database without altering the original database. MsiDatabaseGetPrimaryKeys Returns a record containing the names of all the primary key columns for a specified table. This function returns a handle that should be closed using MsiCloseHandle. MsiDatabaseImport Imports an installer text archive table into an open database. MsiDatabaseIsTablePersistent Returns an enumeration describing the state of a particular table. MsiDatabaseMerge Merges two databases together, allowing duplicate rows. MsiDatabaseOpenView Prepares a database query, creating a view object. MsiFormatRecord Formats record field data and properties using a format string. MsiViewModify Modifies a database record. For a running installation, only temporary database changes are allowed. MsiOpenDatabase Opens a database file for data access. This function returns a handle that should be closed using MsiCloseHandle. MsiViewClose Closes an executed database view. MsiViewExecute Executes a SQL query. MsiViewFetch Fetches a record for the current database view. MsiRecordGetString Returns the string stored in a specific field of the specified record. MsiRecordSetString Sets the string stored in a specific field of the specified record. MsiRecordReadStream Returns the string value of a record field. MsiRecordSetStream Sets a record stream field from a file. Stream data cannot be inserted into temporary fields. MsiRecordGetInteger Returns the integer stored in a specific field of the specified record. MsiRecordSetInteger Sets the integer stored in a specific field of the specified record. MsiViewGetColumnInfo Returns a record containing database column names or definitions. MsiRecordGetFieldCount:Returns the number of fields (columns) in a record. MsiCloseHandle Closes a database, view, or record handle. MsiCloseAllHandles Closes all open handles. Provided for diagnostic purposes, and should not be called for general cleanup. MsiViewGetError Returns an error code for an error generated by MsiViewModify. Summary Information Stream Management Functions MsiGetSummaryInformation obtains a handle to summary information data for an installer database. This function returns a handle that should be closed using MsiCloseHandle. MsiSummaryInfoGetProperty Gets a single property from the summary information. MsiSummaryInfoSetProperty Sets a single summary information property. Miscellaneous Functions MsiApplyPatch For each product listed by the patch package as eligible to receive the patch, the MsiApplyPatch function invokes an installation and sets the PATCH property to the path of the patch package. MsiCreateRecord Creates a new record object with the specified number of fields. This function returns a handle that should be closed using MsiCloseHandle. MsiDoAction Executes a built-in action, custom action, or user-interface wizard action. MsiEvaluateCondition Evaluates a conditional expression containing property names and values. MsiInstallProduct Installs or uninstalls a product. MsiOpenPackage Opens a package for use with the functions that access the product database. The MsiCloseHandle function must be called with the handle when the handle is no longer needed. MsiPreviewBillboard Displays a billboard within a host control in the displayed dialog. Supplying a null billboard name removes any billboard displayed. MsiPreviewDialog Displays a dialog box as modeless and inactive. MsiProcessMessage Sends an error record to the installer for processing. MsiSequence Executes another action sequence, as described in the specified table. | ||
Related Raadings: 1. Windows Installer Development Tools 2. A couple of notes about the contents of the Windows Installer 4.5 SDK 3. Windows Installer Tools & Tips 4. Wrapping the Windows Installer 2.0 API 5. Installer Functions | ||