September 17, 2012

Uninstallation: AskYesNo/MessageBox is hidden behind the progress bar dialog?

Based on the requirement, you may add a Message Box or Yes / No confirmation dialog to the uninstallation sequence using InstallScript Custom Action. When you try to uninstall the application on a Windows Vista environment, these prompts (modal dialog) will be hidden behind the Screen and you will be waiting indefinitely until you press ALT + TAB to view the same.
To overcome this problem, following InstallScript function can be used.
 // Function Delaration
export prototype MyFunction(HWND);
 // Function Definition
function MyFunction(hMSI)
// To Do: Declare local variables.
HWND hRecord,hInst;
begin

hRecord = MsiCreateRecord(1);
MsiRecordSetString( hRecord, 0, "UninstallMessage");
MsiProcessMessage(hInst, INSTALLMESSAGE_USER|MB_YESNO, hRecord);
MsiCloseHandle(hRecord);
end;
 Note: This code sample applies to Basic MSI Projects and verified with InstallShield 2010, 2011 & 2012 SP1.
 Also kindly refer the below MSDN article regarding MsiProcess message function.

2 comments:

  1. Hi,

    Kindly help to solve this issue in InstallShield 2009. any workaround..

    regards,
    Jitendra

    ReplyDelete
  2. However this is NOT supposed to work for silent /qn installs, right? Or is there another way to use the MsiProcessMessage api to get this to work for silent installs so that it does not always return '0'?

    ReplyDelete