Outlookを検索し、ユーザーにOutlookを強制終了するように求めるWixカスタムアクションがあります。私は自分でOLを殺したくはありませんが、ユーザーに殺してもらいたいのです。これが私のカスタムアクションです:
[CustomAction]
public static ActionResult PromptToCloseOutlook(Session session)
{
session.Log("Detecting running instances of Microsoft Outlook...");
ActionResult retVal = ActionResult.Success;
Process outlook;
while (null != (outlook = Process.GetProcessesByName("outlook").FirstOrDefault()))
{
session.Log("Microsoft Outlook is running.");
var result = session.Message(
// See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa371614(v=vs.85).aspx
InstallMessage.FilesInUse,
new Record(null, "outlook.exe", outlook.Id)
);
session.Log("User selected option:" + result);
if (result == MessageResult.Cancel)
{
session.Log("User does not wish to close Outlook at this time.");
retVal = ActionResult.UserExit;
}
else if (result == MessageResult.Ignore)
{
session.Log("User wished to ignore and proceed.");
break;
}
}
return retVal;
}
私はこれを次のように呼び出します:
<Custom Action="CA.PromptToCloseOutlook" Before="InstallValidate" />
ただし、Win7で実行すると、空白のウィンドウが表示されます(ただし、OLが閉じられるまで正しく待機します)
WinXPでは、PIDが無効であると言って、ループが永久に実行されます。実行中のインスタンスのPIDを使用しているため、それがどのように可能かわかりません。
コードの何が問題になっていますか?