首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MsiConfigureFeature失败,属性为suppress reboot

MsiConfigureFeature失败,属性为suppress reboot
EN

Stack Overflow用户
提问于 2021-02-25 21:31:47
回答 2查看 57关注 0票数 1

我正在尝试卸载我的功能,并想抑制重启,但它失败了,错误为1618

代码语言:javascript
复制
MsiOpenProductA(productCode, &handle))

    MsiSetPropertyA(handle, "REBOOT", "ReallySuppress");
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    Ret = MsiConfigureFeatureA(
                            productCode,
                            feature,
                            INSTALLSTATE_ABSENT);
    if (ERROR_SUCCESS == Ret) {
        std::cout << "myFeature is uninstalled\n";
    }
    else {
        std::cout << "myFeature is not uninstalled "<

It is failing with error 1618 i.e. Another installation is already in progress. Complete that installation before proceeding with this install I suspect this is happening because I opened handle.

ANyone came acrross this would be great help

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-02-25 23:45:57

请参阅我的另一个答案,了解是什么原因导致了您的

错误[error 1618](https://docs.microsoft.com/en-us/windows/win32/msi/error-codes) -在此期间,请查看此站点以查找奇怪的错误代码:https://www.magnumdb.com/)。

新版本:这是代码的另一个版本。它使用ConfigureProductEx并设置命令行来删除该功能。也许还有更好的方法。请测试此操作是否不会删除超过预期的功能..。请仔细检查文档here(有限测试):

步骤:在运行以下示例之前,请执行以下操作:

以管理员身份运行(以管理员身份启动Visual Studio )。

将下面的产品代码更新为您自己的代码。如何查找您的产品code](https://stackoverflow.com/questions/29937568/how-can-i-find-the-product-guid-of-an-installed-msi-setup/29937569#29937569) [How to find your product (vbscript)。

代码语言:javascript
复制
#define WIN32_LEAN_AND_MEAN // Minimize includes from Windows.h
#include 
#include  // Windows Installer
#include  

#pragma comment(lib, "msi.lib") // To make code link

int main()
{
    // NB! RUN CODE WITH ADMIN RIGHTS

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    // The below command line suppresses reboot and removes the specified feature
    const TCHAR commandline[] = _T("REBOOT=ReallySuppress REMOVE=FeatureNameToRemove");
    const TCHAR prodcode[39] = _T("{00000000-0000-0000-0000-000000000000}");

    UINT res = MsiConfigureProductEx(prodcode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, commandline);

    return res; // Error Codes: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376931(v=vs.85).aspx
}

链接:

What does WIN32_LEAN_AND_MEAN是什么 真的是这样吗?

MSI [不使用msiexec]从命令行卸载文件(位于底部的第14节)

票数 1
EN

Stack Overflow用户

发布于 2021-02-25 23:12:30

简短回答:你不需要先打开产品,它会启动两个锁而不是一个锁。下面是一个Visual Studio 2019示例,您可以使用它进行测试。

程序:在运行以下示例之前,请执行以下操作:

  1. 以管理员身份运行(以管理员身份启动Visual Studio )。
  2. 将下面的产品代码更新为您自己的代码。如何查找您的产品code(vbscript)。
代码语言:javascript
复制
#define WIN32_LEAN_AND_MEAN // Minimize includes from Windows.h
#include 
#include 
#include  // Windows Installer

#pragma comment(lib, "msi.lib") // To make code link

int main()
{
   // NB! RUN CODE WITH ADMIN RIGHTS

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    // Put your own MSI's product code as the first parameter below:
    int r = MsiConfigureFeature(TEXT("{00000000-0000-0000-0000-000000000000}"), 
                                TEXT("FeatureName"), INSTALLSTATE_ABSENT);

    if (ERROR_SUCCESS == r) {
        std::cout << "myFeature is uninstalled\n";
    }
    else {
        std::cout << "myFeature is not uninstalled " << r << std::endl;
    }
}

互斥:只有一个MSIInstallExecuteSequence可以一次运行。AMutex在此序列启动时设置,然后直到释放第一个序列时才能启动其他类型的序列。换句话说,OpenProduct和MsiConfigureFeature都会尝试设置互斥锁,第二次尝试会失败。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66369518

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档