Search code examples
windowswindows-installer

failing MsiConfigureFeature with property suppress reboot


I am trying to uninstall my feature and wanted to suppress reboot, but it is failing with error 1618

   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 "<<Ret<<std::endl;
    }

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


Solution

  • Please see my other answer for technical details on what caused your error 1618 - and while we are at it, check this site to look up strange error codes: https://www.magnumdb.com/).


    New Version: Here is another version of the code. It uses ConfigureProductEx with a command line set to remove the feature. There might be better ways. Please test that this does not remove more features than it should. Please double check the documentation here (limited testing):

    Procedure: Before running the below sample, please do as follows:

    1. Run as administrator (launch Visual Studio as admin).
    2. Update product code below to your own. How to find your product code (vbscript).
    #define WIN32_LEAN_AND_MEAN // Minimize includes from Windows.h
    #include <windows.h>
    #include <msi.h> // Windows Installer
    #include <tchar.h> 
    
    #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
    }
    

    Links: