1

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

user3664223
  • 305
  • 3
  • 19

2 Answers2

1

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:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Did your code actually reboot your computer without warning? I have seen that before when you set MsiSetInternalUI, but I didn¨'t test this particular code with that. I was running on my main box and not a virtual. – Stein Åsmul Feb 25 '21 at 20:27
0

Short Answer: You don't need to open the product first, it initiates two locks instead of one. Below is a Visual Studio 2019 sample you can test with.


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 <iostream>
#include <windows.h>
#include <msi.h> // 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;
    }
}

Mutex: Only one MSI InstallExecuteSequence can run at a time. A Mutex is set when this sequence starts and then no other sequences of that kind can start until the first one is released. In other words both OpenProduct and MsiConfigureFeature will try to set the mutex and it fails for the second attempt.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164