I have a custom action that runs at the time of installation which is an exe written in C#. This exe grants permission to a User to a specific folder, if this task fails there is no use for the installation to continue. I need it to rollback, but only after displaying appropriate error message.
Now what I have tried is the following
My need
To rollback the installation on reading a failure entry from registry.
The script that I have written
function CheckRegistry(hMSI)
STRING keyValue;
NUMBER nType, nSize;
begin
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBGetKeyValueEx ("CSVExtraction", "AccessGranted", nType, keyValue,nSize) < 0) then
MessageBox ("RegDBGetKeyValueEx failed.", SEVERE);
abort;
else
if(keyValue != "true") then
MessageBox("Granting access to the Installation Folder failed; Hence exiting installation",SEVERE);
abort;
endif
endif
end;
There is no way to do what you ask. You could show a message from your EXE before returning a non-zero exit code, but then Windows Installer would still show the Error 1722 message.
If you can instead run a function from a DLL, you have more options. Instead of returning errors, you'd be able to set properties (assuming this is an immediate mode action), and could use those properties to do further things, such as show another dialog, or exit the installation without the Error 1722 message.
Credit: Old answer to similar problem