卸载不工作在安装过程中一个应用程序 [英] Uninstall a application during installation not working

查看:205
本文介绍了卸载不工作在安装过程中一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发C#WPF应用程序。目前我的MSI安装在machine.I当前的应用程序需要卸载两个安装新的(MSI)的过程中支持现有版本的应用程序。



我编写的代码卸载应用程序编程当我调用应用程序的卸载方法installer.cs 这不起作用。同样的方法成功卸载两个应用,当我从比其他项目的另一部分叫 installer.cs



卸载方法:

 公共静态字符串GetUninstallCommandFor(字符串productDisplayName)
{
的RegistryKey LOCALMACHINE = Registry.LocalMachine;
串productsRoot = @SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products
的RegistryKey产品= localMachine.OpenSubKey(productsRoot);
的String [] = productFolders products.GetSubKeyNames();

的foreach(在productFolders串P)
{
的RegistryKey installProperties = products.OpenSubKey(P + @\InstallProperties);
如果(installProperties!= NULL)
{
字符串显示名=(字符串)installProperties.GetValue(显示名称);
如果((显示名= NULL)及!及(displayName.Contains(productDisplayName)))
{
字符串文件名=msiexec.exe的;
字符串参数=/ X {4F6C6BAE-EDDC-458B-A50F-8902DF730CED};

的ProcessStartInfo PSI =新的ProcessStartInfo(文件名,参数)
{
CreateNoWindow = TRUE,
UseShellExecute =假,
RedirectStandardOutput = TRUE
};

工艺过程=的Process.Start(PSI);

process.WaitForExit();

返回uninstallCommand;
}
}
}

返回;
}



更新:使用后WIX MSI安装程序



我已经创造了维克斯的CustomAction项目,使用WIX.Please看到我Product.wxs



<$还创建了安装项目p $ p> < InstallExecuteSequence>
<自定义操作='ShowCustomActionCustomAction'='InstallFinalize'>后,没有安装< /自定义>
< / InstallExecuteSequence>



我的代码在CustomAction.cs.When卸载3个应用程序运行我的WIX微星,它安装新的应用程序,并卸载剩余的两个应用程序中的第一application.The不卸载,我注意到,第一次申请的成功卸载后,用户界面​​关闭,没有任何反应。



灿你能告诉我怎么安装我的微星维克斯期间卸载3应用程序。



更​​新2:

 <资源ID =PREVIOUSVERSIONSINSTALLED安全=YES/> 
<升级n =89CF8BE7-05EE-4C7E-9EFC-0249DD260EBB>
< UpgradeVersion
最短=1.0.0.0最大=99.0.0.0
属性=PREVIOUSVERSIONSINSTALLED
IncludeMinimum =YESIncludeMaximum =NO/> ;
< /升级>
< InstallExecuteSequence>
< RemoveExistingProducts之前=InstallFinalize/>
< / InstallExecuteSequence>
< /产品与GT;

在product.wxs上述设置被卸载以前的版本以及与此安装新one.Along我需要卸载其它两个依赖应用程序使用also.How维克斯安装程序来卸载应用程序的依赖性



任何一个可以帮助我如何在机器检查已安装的应用程序,安装我的新维克斯微星之前卸载。


解决方案

有是MSI互斥体,防止并发安装/卸载。一切都需要一个安装程序的背景下发生的。这就是说,要做到这一点的方法是创作行插入到表升级教FindRelatedProducts和RemoveExistingProducts删除已安装的MSI的附加。



您不提你使用创建MSI所以我不能告诉你如何做到这一点。



您现在已经提到,您使用的是VDPROJ。此工具不支持创作你正在尝试做的。我的建议是使用Windows Installer XML(WiX的汽车)及作者多次升级元素去除各种产品,以重构。


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 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products";
            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.

解决方案

There is a mutex in MSI that prevents concurrent installation / uninstalls. Everything has to happen within the context of a single installer. That said, the way to do that is to author rows into the Upgrade table to teach FindRelatedProducts and RemoveExistingProducts to remove the additional installed MSIs.

You don't mention what you are using to create your MSI so I can't show you how to do that.

You've now mentioned that you are using VDPROJ. This tool doesn't support authoring what you are trying to do. My suggestion is to refactor using Windows Installer XML (WiX) and author multiple Upgrade elements to remove the various products.

这篇关于卸载不工作在安装过程中一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆