2

I have a Wix Custom Action that looks for Outlook and prompts the user to kill it. I don't want to kill OL myself but, want the user to do it. Here's my Custom Action:

[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;
    }

I invoke this as:

<Custom Action="CA.PromptToCloseOutlook" Before="InstallValidate" />

However, when it runs on Win7, it shows a blank window (but correctly waits till OL is closed) empty window

On WinXP, the loop runs for ever, saying the PID is invalid. Since, I use the PID from the running instance, I'm not sure how that's possible.

Any ideas what's wrong with the code?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.