CloseApplication while uninstalling - wix
Asked Answered
P

1

9

I am using Wix 3.6. I have an issue, while uninstalling if any window is open and shown in task bar (this window is a part of my msi, which I am trying to uninstall), it is showing a dialog box asking the user to close the application (“The following application should be closed before continuing the install”).

I tried the following, but no luck.

<InstallExecuteSequence>
       <Custom Action="WixCloseApplications"
                Before="InstallInitialize">Installed</Custom>
       <Custom Action="StartMonitor"
                After="StartServices">NOT Installed</Custom>
    </InstallExecuteSequence>

   <util:CloseApplication Id="CloseMonitor" Target="Monitor.exe"
                           CloseMessage="yes" RebootPrompt="no">
        Installed
    </util:CloseApplication>

I want the wix to detect the applications and close them as part of uninstallation process. No need of showing the dialog box prompt. Can anyone please help me to implement it.

It works fine with it is installed from command prompt with /qn switch but without /qn switch I get the dialog (“The following application should be closed before continuing the install”). Can someone please help me on how to fix this.

Piggin answered 21/9, 2012 at 9:34 Comment(1)
I changed InstallInitialize to InstallValidate and it worked fine <Custom Action="WixCloseApplications" Before="InstallValidate ">Installed</Custom>Piggin
E
0

Add a C# custom event and add make it first event on InstallUISequence and use following code for kill the process:

try
{
      Process proc = Process.GetProcessesByName("MyApplication");
      proc.Kill();
}
catch (Exception ex)
{
      MessageBox.Show(ex.Message.ToString()); 
}

and if ur application support multiple instances then count the no. of instances first:

 int count = 0;
 Process[] process = Process.GetProcessesByName("MyApplication");
 foreach (Process pr in process)
 {
   if (pr.MainModule.FileName.Equals(Assembly.GetExecutingAssembly().Location,                StringComparison.OrdinalIgnoreCase))
     {
       count++;

     }
 }

And if you are not at all using and DllEntry then follow this link

Ephrem answered 21/9, 2012 at 9:51 Comment(4)
I was asked not to use C#, so did not try your suggestion.Piggin
see wix has very less inbuilt action or function so you have to use external code. it may be c# or any other language.Ephrem
I changed InstallInitialize to InstallValidate and it worked fine <Custom Action="WixCloseApplications" Before="InstallValidate ">Installed</Custom>Piggin
@Piggin In that case, give an answer to your own question and accept it. So that in future if u or someone else refer this question may know the solutionEphrem

© 2022 - 2024 — McMap. All rights reserved.