installationwixwindows-installerwix3.11

How to add a warning message if app is open and user want to uninstall it


I created a bootstrapper EXE file which have .Net prerequisite and my MSI chained together. I am able to install/uninstall successfully using this EXE.

Now customer wants a condition where he should see a warning message if app is open and user trying to uninstall it. Is it possible to do this job with standardBootstrapper or I should write custom BA. I really dont know which condition and code I should write for this if custom is the only solution. Any lights in this will be a great help.


Solution

  • If you're using standard bootstrapper the best way is to add custom action to your msi. Just add property (for example IsRunning='0' ), and change it using custom action when program is running.

    [CustomAction]
    public static ActionResult CustomAction(Session session)
    {
         if (Process.GetProcessesByName("process_name").Length > 0)
         {
            session["IsRunning"] = 1;
         }
         return ActionResult.Success;
    }
    

    See this answer for more info about custom actions. And here's uninstall custom action sample

    Then add dialog to sequence that will be shown depending on that property.

    If you are using custom bootstrapper, you can just add that check to your code before your msi will be run, or before you'll show UI