Kryptonic
Posts: 10
Joined: Thu Oct 16, 2008 12:43 pm

Uninstall - Ask user question, then do something else!

Hi all,

My boss has asked me to modify the installers uninstall action. Currently, when we uninstall the application there is a .net custom action that cleans up a load of stuff and does some other work... But, what I've been asked is, is it possible to prompt the user with a "yes / no" type question on the installer and then depending on that response run the custom uninstall script?

Is this possible?

Cheers!
Will
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Uninstall - Ask user question, then do something else!

Hi Will,

Yes, this can be done with another custom action. Here is some sample VBScript code:

Code: Select all

Function Ask
   MsiMsgBox("Do you want to completely uninstall the application?")	
End Function
      
Function MsiMsgBox(msg)
  Const msiMessageTypeUser = &H03000000
  Const msiMessageStatusYes = 6
  Set record = Session.Installer.CreateRecord(1)
  record.StringData(0) = "[1]"
  record.StringData(1) = CStr(msg)
  ans=Session.Message(msiMessageTypeUser + vbYesNo, record)
  If ans=msiMessageStatusYes Then
     Session.Property("UNINSTALL_COMPLETE")="YES"
  Else
     Session.Property("UNINSTALL_COMPLETE")="NO"
  End If
End Function
This custom action will set the "UNINSTALL_COMPLETE" property to "YES" or "NO", depending on the answer of the user. You can use this property to condition the custom action which does the cleanup. Please note that the condition of a custom action can be set in the "Expression" field of the Custom Action Properties page.

The above custom action can be scheduled under "InstallExecuteSequence" -> "Begin" with the condition:

Code: Select all

(REMOVE = "ALL") AND (UNINSTALL_COMPLETE = "YES")
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”