I am developing WPF application in C#. Currently my msi install the current application in machine.I need to uninstall two supporting application of existing version during the installation of new one(msi).
I written code to uninstall application programmatically and this does not work when i call the application uninstallation method in installer.cs
.The same method uninstall the two application successfully when i call from other part of project other than installer.cs
.
uninstallation method:
public static string GetUninstallCommandFor(string productDisplayName)
{
RegistryKey localMachine = Registry.LocalMachine;
string productsRoot = @"SOFTWAREMicrosoftWindowsCurrentVersionInstallerUserDataS-1-5-18Products";
RegistryKey products = localMachine.OpenSubKey(productsRoot);
string[] productFolders = products.GetSubKeyNames();
foreach (string p in productFolders)
{
RegistryKey installProperties = products.OpenSubKey(p + @"InstallProperties");
if (installProperties != null)
{
string displayName = (string)installProperties.GetValue("DisplayName");
if ((displayName != null) && (displayName.Contains(productDisplayName)))
{
string fileName = "MsiExec.exe";
string arguments = "/x{4F6C6BAE-EDDC-458B-A50F-8902DF730CED}";
ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments)
{
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true
};
Process process = Process.Start(psi);
process.WaitForExit();
return uninstallCommand;
}
}
}
return "";
}
Update:After using WIX MSI Installer
I have created the CustomAction project in WIX, also created the Setup project using WIX.Please see my Product.wxs
<InstallExecuteSequence>
<Custom Action='ShowCustomActionCustomAction' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
I have the code to uninstall 3 application in CustomAction.cs.When i run my WIX MSI,it install the new application and uninstall the first application.The remaining two application are not uninstalled,i noticed that after successful uninstall of first application the UI closes and nothing happens.
Can you tell me how to uninstall the 3 application during the installation of my WIX MSI.
Update 2:
<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="89CF8BE7-05EE-4C7E-9EFC-0249DD260EBB">
<UpgradeVersion
Minimum="1.0.0.0" Maximum="99.0.0.0"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallFinalize" />
</InstallExecuteSequence>
</Product>
the above settings in product.wxs is uninstalling the previous version and install the new one.Along with this i need to uninstall another two dependency application also.How to uninstall the dependency application using wix installer.
Can any one help me how to check the installed application in the machine and uninstall that before installation of my new wix msi.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…