卸载C#应用程序 - InstallShield试用版

时间:2021-11-04 17:05:17

I have a C# application installed with InstallShield Evaluation Version 2013, and I want to uninstall it from another C# application

我有一个安装了InstallShield Evaluation Version 2013的C#应用​​程序,我想从另一个C#应用程序中卸载它


I run the process to uninstall it like this:

我运行这个过程卸载它像这样:

p.StartInfo.FileName = "msiexec.exe";

p.StartInfo.FileName =“msiexec.exe”;

            p.StartInfo.UseShellExecute = false;
            p.StartInfo.Arguments = "/x {XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}";
             p.Start();

And the result is an error message:

结果是一条错误消息:

"The action is only valid for products that are currently installed"

“该操作仅对当前安装的产品有效”

The product is installed with InstallShield Trial Version. If I installed the product with Limited InstallShield, the uninstall process executes perfectly.

该产品随InstallShield试用版一起安装。如果我使用Limited InstallShield安装产品,卸载过程将完美执行。


Is this problem because it is an evaluation version, or I am missing something else?

这个问题是因为它是一个评估版本,还是我错过了其他的东西?

2 个解决方案

#1


0  

If the GUID of the product has changed in between versions of InstallShield (which is very likely if you let it create a default GUID) then it is probably looking for the old GUID in the registry to uninstall. You may need to clean up the old registry entry manually. There is information about doing that here.

如果产品的GUID在InstallShield版本之间发生了变化(如果您让它创建默认GUID,则很可能),那么它可能正在寻找要卸载的注册表中的旧GUID。您可能需要手动清理旧的注册表项。这里有关于这样做的信息。

#2


0  

Most likely you got the wrong GUID as Jeff points out. You can find several ways to find the right one in this answer on how to uninstall an MSI: MSI uninstall details. Or better yet, go straight to this answer on how to find the product GUID for your setup: How can I find the product GUID of an installed MSI setup?

杰夫指出,你很可能得到了错误的GUID。您可以在此答案中找到几种方法来找到有关如何卸载MSI的正确方法:MSI卸载详细信息。或者更好的是,直接回答有关如何为您的设置找到产品GUID的答案:如何找到已安装的MSI设置的产品GUID?

I would also try to build the command line in code, serialize it to a string and manually try it using msiexec.exe in a command window to verify its validity. It is a complex, error prone command line interface. Your error message indicates a wrong GUID though.

我还尝试在代码中构建命令行,将其序列化为字符串,并在命令窗口中使用msiexec.exe手动尝试以验证其有效性。它是一个复杂的,容易出错的命令行界面。您的错误消息表明错误的GUID。

Finally: Instead of invoking msiexec.exe as a command line, you can use DFT - Deployment Tools Foundation which is a .NET wrapper for the Win32 Windows Installer API. No command line to build or error codes to check, just easy to use .NET classes to deal with all aspects of MSI. This will allow you to run uninstall via code that supports even exception handling properly. DTF is distributed as part of Wix as explained here. See this post on serverfault.com (system administrator site) for a better rundown of the different approaches. And see a sample C# code snippet for its use in MSI uninstall details.

最后:您可以使用DFT - Deployment Tools Foundation(它是Win32 Windows Installer API的.NET包装器),而不是将msiexec.exe作为命令行调用。没有要构建的命令行或要检查的错误代码,只是易于使用.NET类来处理MSI的所有方面。这将允许您通过代码运行卸载,该代码甚至可以正确地支持异常处理。 DTF作为Wix的一部分分发,如此处所述。请参阅serverfault.com(系统管理员站点)上的这篇文章,以便更好地了解不同的方法。并查看示例C#代码段,以便在MSI卸载详细信息中使用它。

#1


0  

If the GUID of the product has changed in between versions of InstallShield (which is very likely if you let it create a default GUID) then it is probably looking for the old GUID in the registry to uninstall. You may need to clean up the old registry entry manually. There is information about doing that here.

如果产品的GUID在InstallShield版本之间发生了变化(如果您让它创建默认GUID,则很可能),那么它可能正在寻找要卸载的注册表中的旧GUID。您可能需要手动清理旧的注册表项。这里有关于这样做的信息。

#2


0  

Most likely you got the wrong GUID as Jeff points out. You can find several ways to find the right one in this answer on how to uninstall an MSI: MSI uninstall details. Or better yet, go straight to this answer on how to find the product GUID for your setup: How can I find the product GUID of an installed MSI setup?

杰夫指出,你很可能得到了错误的GUID。您可以在此答案中找到几种方法来找到有关如何卸载MSI的正确方法:MSI卸载详细信息。或者更好的是,直接回答有关如何为您的设置找到产品GUID的答案:如何找到已安装的MSI设置的产品GUID?

I would also try to build the command line in code, serialize it to a string and manually try it using msiexec.exe in a command window to verify its validity. It is a complex, error prone command line interface. Your error message indicates a wrong GUID though.

我还尝试在代码中构建命令行,将其序列化为字符串,并在命令窗口中使用msiexec.exe手动尝试以验证其有效性。它是一个复杂的,容易出错的命令行界面。您的错误消息表明错误的GUID。

Finally: Instead of invoking msiexec.exe as a command line, you can use DFT - Deployment Tools Foundation which is a .NET wrapper for the Win32 Windows Installer API. No command line to build or error codes to check, just easy to use .NET classes to deal with all aspects of MSI. This will allow you to run uninstall via code that supports even exception handling properly. DTF is distributed as part of Wix as explained here. See this post on serverfault.com (system administrator site) for a better rundown of the different approaches. And see a sample C# code snippet for its use in MSI uninstall details.

最后:您可以使用DFT - Deployment Tools Foundation(它是Win32 Windows Installer API的.NET包装器),而不是将msiexec.exe作为命令行调用。没有要构建的命令行或要检查的错误代码,只是易于使用.NET类来处理MSI的所有方面。这将允许您通过代码运行卸载,该代码甚至可以正确地支持异常处理。 DTF作为Wix的一部分分发,如此处所述。请参阅serverfault.com(系统管理员站点)上的这篇文章,以便更好地了解不同的方法。并查看示例C#代码段,以便在MSI卸载详细信息中使用它。