9

我正在使用 Wix 3.6。我有一个问题,在卸载时如果任何窗口打开并显示在任务栏中(此窗口是我的 msi 的一部分,我正在尝试卸载它),它显示一个对话框,要求用户关闭应用程序(“在继续安装之前应关闭以下应用程序”)。

我尝试了以下方法,但没有运气。

<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>

我希望 wix 检测应用程序并在卸载过程中关闭它们。无需显示对话框提示。谁能帮我实现它。

它可以正常工作,它是使用 /qn 开关从命令提示符安装但没有 /qn 开关我得到对话框(“在继续安装之前应关闭以下应用程序”)。有人可以帮我解决这个问题。

4

1 回答 1

1

添加C#自定义事件并添加使其成为第一个事件InstallUISequence并使用以下代码终止进程:

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

如果你的应用程序支持多个实例,那么就数数。首先是实例:

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

     }
 }

如果您根本不使用,请DllEntry点击此链接

于 2012-09-21T09:51:58.517 回答