How to prompt error message when Wix installer failed - wix

I am writing a wix project to deploy a website.
I am using the <iis:Certificate> element.
If the CertificatePath is not correct, or the PFXPassword is not correct, the installation failed, but the installer didn't prompt error message. I could only find the error in the log file.
Is there any way to prompt the user about the installation failure if there any error happens?

This is the way iis:Certificate element is implemented. Basically, it is a deferred custom action behind the scenes, which receives the information from another custom action and tries to do its job using the data it got.
All checks should go before the deferred part starts. I suspect that you pass the CertificatePath and PFXPassword as properties, and perhaps user enters the values. Anyway, you have to validate the values of those properties before letting it go further. If the value is not what you expect, you should prompt the user to fix it and don't let the installation flow to proceed without this.
It can be a custom action which is tied to the Next button on a wizard and doesn't let you move to the next dialog unless the properties are valid.

Related

MSI: Show message box in UI phase of installation

I'm updating an InstallShield based installer. I've added a new managed custom action, written in C#, and packaged using Wix DTF.
Action is invoked correctly, and performs necessary actions.
Problem I have is showing an error message to user.
Method 1: MsiProcessMessage
From articles I've read, I understood that MsiProcessMessage is the correct way to do it, however this method does not work in UI sequence (before setup actually starts copying files and modifying system). In install sequence this method works. Code which I use is following:
Record record = new Record() { FormatString = "Password is not valid for this user." };
session.Message(
InstallMessage.Error | (InstallMessage)(MessageBoxIcon.Error) | (InstallMessage)MessageBoxButtons.OK,
record
);
Is it actually impossible to show an error message in UI sequence (Immediate execution) using MsiProcessMessage?
Method 2: MessageBox.Show
Using Windows.Forms works for showing a message box. However, message is displayed in background of setup wizard, and shows a separate icon in Windows taskbar.
Is there a way to get window handle of installation wizard, and that way solve this problem?
You didn't quite mention this, but I'm guessing that you are invoking your custom action off a DoAction ControlEvent, published off of something like a button click. Underneath the covers, this is very different from scheduling it in the InstallUISequence. MsiProcessMessage doesn't work from DoAction.
For proper integration with the Windows Installer UI experience, you should avoid using MessageBox.Show (your method 2). Better-integrated options include:
Tweaking a message that can be shown on the dialog from which you invoke this action
Showing a popup message by conditionally invoking a SpawnDialog ControlEvent
Showing an additional wizard panel by conditionally invoking a NewDialog ControlEvent
All three of those involve editing the UI of your project, but differently.

Windows Installer : SpawnAndWaitDialog not getting closed automatically?

I am using a C# custom action followed by a SpawnAndWait Dialog.
Something Like
PROPERTY WORK_DONE="False"
1.LaunchCustomAction (This does some work and sets WORK_DONE to True)
2.Show SpawnAndWait (Exit when WORK_DONE="True")
Problem,For SpawnAndWait Dialog to Appear, I need to mark my CustomAction as
asynchronous, that is to continue installation without waiting for the custom action to finish. But Whenever I do this, Properties are not getting updated and as a result SpawnAndWait Dialog doesn't get closed automatically.
If I don't mark my Condition as async, The dialog doesn't appear and it waits for the custom action to finish first.
My Requirement is to Show a small popup window that lets the user know that there is a background task going on, Please wait.
Please let me know what am I doing wrong.
I am using C# custom Action via Wix Toolset to build the custom action and AdvancedInstaller to build the installer.
I would highly recommend you (if you are willing to) to write your custom action as an unmanaged custom action written in native C++ and use the MsiSetProperty function to set your property. There are lots of Windows Installer incompatibilities and limitations in what regards its integration with managed custom actions.
If you still need to use a managed C# custom action please try to add your custom action as a custom action with sequence in Advanced Installer if this configuration is suitable for your scenario.

bootstrapper application rollback

I am trying to create a Wix burn bootstrapper that installs my msi. The bootstrapper exe is working fine but the only issue is that whenever I try to cancel the installation in midway the custom actions which are added in msi is not get stopping. Can anyone tell how to stop and rollback the installation while clicking cancel button. Thanks in advance.
A custom action must send ::MsiProcessMessage() calls to provide the possiblity to recieve the cancel and handle the return code from that API (usually ERROR_INSTALL_USEREXIT or IDCANCEL). Then the custom action must exit.
If you look at some of the WiX standard custom actions you'll see lots calls to WcaProcessMessage() and such. We save the return code from those and WcaFinalize() returns the correct thing on exit. Check out src\ca\wcautil\wcautil.cpp and src\ca\wcautil\wcawrap.cpp for example code.

Show custom dialog with Launch Condition

I would like to show the my custom dialog rather than the message box when Launch Condition failed in Wix. Normally, the message box of Launch Condition has OK button, but I would like to make more than that with some further actions with my dialog.
Could you please advise me how I can make it?
Thanks.
Dialogs can be sequenced using the InstallExecuteSequence and Custom elements. Schedule it prior to your Welcome dialog and after the LaunchConditions action. You may want an error custom action scheduled in the execute sequence to handle logging during silent installs.
You may also want to author your dialog into the main wizard loop (after install welcome ) using Publish elements also. It's hard to say without understanding your exact needs.

How to report msi installation status on quiet install

I'm trying to do a quiet install using a Wix created msi. The thing is that there is absolutely no reporting on how the install has gone, i.e. whether it's succeeded or not.
At the moment, I'm logging everything to a file and checking the file afterwards, I'm just wondering whether there is a better way?
TIA
When you run an msi silently, msiexec will have an exit code. 0 and 3010 is 'good' (3010 means reboot needed ) everything else ( especially 1603 ) is bad.
List of error codes and error messages for Windows Installer processes
I would say this is what quiet install is all about - install quietly. :)
You might want to examine other command line switches starting from /q. This is the excerpt from the article about msiexec.exe:
/qn : Displays no user interface.
/qb : Displays a basic user interface.
/qr : Displays a reduced user interface with a modal dialog box
displayed at the end of the installation.
/qf : Displays the full user interface with a modal dialog box
displayed at the end.
/qn+ : Displays no user interface, except for a modal dialog box
displayed at the end.
/qb+ : Displays a basic user interface with a modal dialog box
displayed at the end.
/qb- : Displays a basic user interface with no modal dialog boxes.
If you only need to make sure it's there after the installation yourself, take a look at the add/remove programs console. If it's been installed, it is there (unless you tell it explicitly not to be).
You have gotten the right answer in terms of the exit codes, but I just want to add that another way to allow more "interactivity" whilst still suppressing most of the MSI GUI is to allow a modal dialog to be displayed at the end of the install. This is achieved by adding /QN+ to the msiexec.exe command line:
C:\Windows\system32\msiexec.exe /I "C:\test.msi" /QN+
This will make the install run silently, but a modal dialog will be show at the end of the setup telling you that the install completed.
There are many options with regards to suppressing parts of the GUI sequence, and the command lines to achieve this are sometimes confusing. Please check my post here for a tool that can help to demystify the command line syntax by auto generating it with a simple, free tool.