Your best bet is to create a custom action
i.e. I close Outlook at the beginning of the install, then relaunch it after
the install (if Outlook was indeed closed)
/// <summary>
/// Kills Outlook just as the install/uninstall starts
/// </summary>
/// <param name="session"></param>
/// <returns>return ActionResult.Success</returns>
[CustomAction]
public static ActionResult CloseOutlookProcess(Session session)
{
try
{
if (session == null)
{
throw new ArgumentNullException("session");
}
// set registry key that shut down Outlook succeeded
const string userRoot = "HKEY_LOCAL_MACHINE";
const string key = "SOFTWARE\\MYCORP\\Setup";
const string closeOutlook = "CloseOutlook";
Registry.SetValue(userRoot + "\\" + key, closeOutlook, "0");
// Assuming there won't be any other process with the same name
as outlook :)
Process[] processes = Process.GetProcessesByName("OUTLOOK");
bool allOutlookProcessesExited = true;
if (processes.Length > 0)
{
foreach (Process outlookProcess in processes)
{
try
{
outlookProcess.CloseMainWindow();
// set registry key that shut down Outlook succeeded
Registry.SetValue(userRoot + "\\" + key,
closeOutlook, "1");
// wait some time and check again to see if the
process has exited
System.Threading.Thread.Sleep(4000);
allOutlookProcessesExited =
outlookProcess.HasExited && allOutlookProcessesExited;
}
catch (Exception exception)
{
WriteErrorLogInstall(session, "CloseOutlookProcess;
failed to close Outlook: ", exception, true);
}
finally
{
// dispose process
if (outlookProcess != null)
{
outlookProcess.Dispose();
}
}
}
}
if (!allOutlookProcessesExited)
{
MessageBox.Show(
"Please close any instances of Microsoft Outlook, to
continue with this installation",
"Custom action exception error...",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
WriteErrorLogInstall(session, "CloseOutlookProcess failed: ",
ex, true);
}
return ActionResult.Success;
}
-----Original Message-----
From: Yawar Khan [mailto:[email protected]]
Sent: January-29-13 8:56 AM
To: [email protected]
Subject: [WiX-users] Detect specific running application during installation
with WIX.
Hi,
Can anyone please help me to detect any running process through WIX and ask
user to close it?Following code is detecting the installed application is
running during "repair". But it was not working to detect Internet Explorer
during "installation".
<InstallExecuteSequence> <Custom Action="WixCloseApplications"
Before="InstallInitialize" /></InstallExecuteSequence>
<util:CloseApplication Id="CloseSuperForm" CloseMessage="no" Description="close
it" ElevatedCloseMessage="no" RebootPrompt="no"
Target="myapp.exe" /> <util:CloseApplication Property="MsWordRunning"
Id="CloseIE" CloseMessage="no" Description="Close Internet Explorer"
ElevatedCloseMessage="no" RebootPrompt="no"
Target="iexplore.exe" />
Please also provide the possible choices of "Before" and "Action" under
"Custom" tag.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC,
Windows 8 Apps, JavaScript and much more. Keep your skills current with
LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts.
ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users