我的产品有一个帮助程序可执行文件来卸载所有相关的子产品。我根据所有子产品的升级代码进行卸载。
首先,我使用 MsiEnumRelatedProducts 从升级代码中获取产品代码功能。然后我尝试使用 MsiConfigureProductEx 卸载产品功能。
问题是 MsiConfigureProductEx
返回错误。
Invoked Function: MsiConfigureProductsEx
Return Code: 1605 (0x00000645)
Description: This action is only valid for products that are currently installed.
为什么 MsiEnumRelatedProducts
返回无效的产品代码?我搜索了 Windows 注册表以查看是否存在此类产品代码。没有。如何调试问题?
编辑:添加了重现问题的最少代码。
// UpgradeCodes is an array having upgrade codes of all modules.
TCHAR lpProductCode[GUID_STR_LENGTH];
const TCHAR tszNoReboot[] = _T("REMOVE=ALL REBOOT=ReallySuppress DISABLE_REBOOT_PROMPT=1");
for (size_t i = 0; i < sizeof(UpgradeCodes) / sizeof(UpgradeCodes[0]); i++)
{
tstring tstrUpgradeCode = UpgradeCodes[i];
DWORD dwIndex = 0;
size_t status;
// for each of the upgrade code, get all the products
do
{
status = MsiEnumRelatedProducts(UpgradeCodes[i],
0,
dwIndex,
lpProductCode);
if (ERROR_SUCCESS == status)
{
UINT uiReturn = MsiConfigureProductEx(lpProductCode,
INSTALLLEVEL_DEFAULT,
INSTALLSTATE_DEFAULT,
tszNoReboot);
if (ERROR_SUCCESS_REBOOT_REQUIRED == uiReturn)
{
// prompt for reboot at the end of all modules uninstallation.
}
if (ERROR_SUCCESS != uiReturn)
{
// log message with return code.
// Error Code: 1605 is coming from here.
}
}
}while (ERROR_NO_MORE_ITEMS != status);
}
最佳答案
Some years have passed and I want to add two scipts that can be used to export MSI package information: How can I find the product GUID of an installed MSI setup? - in section 2.
Do visit the link above, but here are direct links to the scripts:
1)
the html export version and2)
the simpler text output.
免责声明:以下信息非常“隐秘”。请尽可能使用 API 调用来访问 MSI 数据库。还请记住在虚拟机上运行所有 MSI 测试,以便轻松恢复到“干净状态”。在 MSI 开发期间,可能会发生奇怪的事情。
您之前卸载该产品可能会在卸载时留下一些注册信息,这会导致所有问题。我会尝试使用脚本检查系统上注册的内容。
在这里找到了关于使用 VBScript 检索产品信息的很好的讨论,一些非常好的脚本 - 推荐。去网站上找脚本,它们的格式很糟糕,阻碍了答案。
- http://forum.installsite.net/index.php?act=ST&f=26&t=14035
- http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/
Windows Installer 数据库 主要位于此处:
- HKEY_CLASSES_ROOT\安装程序\
- 升级代码部分:HKEY_CLASSES_ROOT\Installer\UpgradeCodes
您绝不能直接接触 Windows Installer 数据库注册表中的任何内容。它极其相互关联且容易损坏。只通过 API。请注意,注册表中的 GUID 是打包的,因此您不会从注册表中的包中找到 GUID。
- 打包的 GUID:03B1692A57845354EA63AD602436AB05
- 常规 GUID:{A2961B30-4875-4535-AE36-DA064263BA50}
使用上面的 VBScript 和注册表数据直接进行检查,您应该能够确定 Windows Installer 数据库中发生了什么。
关于windows - 卸载软件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19696828/