This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Hiding the Cancel button on the MSI Progress Dialog
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Hiding the Cancel button on the MSI Progress Dialog
Hiding the Cancel button on the MSI Progress Dialog
Summary
How to hide the cancel button on the MSI Progress DialogSynopsis
This article discusses various techniques for hiding the Cancel button on the various progress dialog boxes displayed by a Windows Installer (Basic MSI) installation.Discussion
Default Progress Dialog BoxesWhile a Windows Installer installation makes changes to a target system, by default it displays feedback to the user on a progress dialog box. For a full-user interface installation or uninstallation, the SetupProgress dialog box is displayed.
For a Basic UI installation?one performed by running the command msiexec /i product.msi /qb or by launching an uninstallation from the Remove button on the Add or Remove Programs tool?a smaller progress dialog box similar to the following is displayed:
In both cases, the progress dialog displays a Cancel button, with which the user can exit the installation. If the installation is running in deferred mode, any rollback actions contained in the execution script will be performed.
Disabling the Cancel Button
In some cases, it is desirable to disable the Cancel button. For a Basic UI installation, the Cancel button can be disabled by adding the exclamation point to the /qb switch, as in msiexec /i product.msi /qb!. In this case, the progress dialog box appears as follows.
Disabling the Cancel button for a full-UI installation requires a custom action. The MsiProcessMessage function and Session.Message method support constants that can suppress the Cancel button while data transfer is taking place. In a VBScript custom action, the code might appear as follows:
Function HideCancel( )
Const msiMessageTypeCommonData = &H0B000000
Set rec = Installer.CreateRecord(2)
rec.IntegerData(1) = 2
rec.IntegerData(2) = 0
Message msiMessageTypeCommonData, rec
HideCancel = 1 ' return success to MSI
End Function
If you call this code in an immediate-mode custom action scheduled in the Execute sequence after InstallInitialize, the SetupProgress dialog box appears as follows.
For a reduced-UI or basic-UI installation, the Cancel button is similarly hidden.
Code for an MSI DLL custom action that performs the same task might appear as follows.
#pragma comment(lib, "msi.lib")
#include <windows.h>
#include <msi.h>
#include <msiquery.h>
UINT __stdcall HideCancelButton(MSIHANDLE hInstall)
{
PMSIHANDLE hRecord = MsiCreateRecord(2);
if (!hRecord)
return ERROR_INSTALL_FAILURE;
MsiRecordSetInteger(hRecord, 1, 2);
MsiRecordSetInteger(hRecord, 2, 0);
MsiProcessMessage(hInstall, INSTALLMESSAGE_COMMONDATA, hRecord);
return ERROR_SUCCESS;
}
By default, because the custom action is called for first-time installations and maintenance operations (including uninstallation), the Cancel button will also be hidden during maintenance mode and uninstallation. If you want control over the circumstances during which the Cancel button is hidden, you can attach a condition to the custom action. For example, to hide the Cancel button only during uninstallation, you can use the condition REMOVE="ALL" in the Execute sequence (somewhere after the InstallValidate action). For more information about this type of condition, see "Conditions to Determine Installation States".
To re-display the Cancel button, you can use a similar custom action, in which the second field of the record passed to Message or MsiProcessMessage is set to 1 instead of 0.
For more information, see the Windows Installer Help Library topics "MsiProcessMessage" and "Session.Message".
No ratings