As an alternative to using the “Rollback” or “InstallException” approach, simply use pinvoke/interop to call the cancel button on the base installer form directly.
(see my related post for more detail and full code)
ShowWindow(msiwindowhandle, ShowWindowCommands.Show);
IntPtr cancelbuttonhandle;
const int BM_CLICK = 0x00F5;
msiwindowhandle = FindWindow("#32770", InstallTitle);
cancelbuttonhandle = FindWindowEx(msiwindowhandle, IntPtr.Zero, "Button", "Cancel");
SetActiveWindow(msiwindowhandle); //necessary for button click to fire
SendMessage(cancelbuttonhandle, BM_CLICK, IntPtr.Zero, IntPtr.Zero);
Leave a comment