Deepak Ingole
Deepak Ingole

Reputation: 15772

msi not getting unistalled properly

I want to revert all my custom action on uninstallation.

Here are my custom action

  1. Create a registry entry using installscript
  2. Install service --> created under launch an executable option
  3. Start Service --> created under launch an executable option

Here is code that I wrote in installscript to add a registry entry

#include "ifx.h"

export prototype SetRegistryParameters(HWND);


function SetRegistryParameters(hMSI)
    NUMBER  ret;
    STRING  formatStr;
begin

    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    SprintfBox(WARNING, "SetRegistryParameters", "Hi from internal", 0);

    ret = RegDBSetKeyValueEx("Software\\XYZ", "InstallDir", REGDB_STRING, INSTALLDIR, -1);
    if (ret < 0) then
        formatStr = "RegSetValue failed with ret: 0x%x";
        SprintfBox(WARNING, "SetRegistryParameters", formatStr, ret);
    endif;

    return ret;

end;

To stop the service and remove it I created custom actions

  1. StopService --> created under launch an executable option
  2. RemoveService --> created under launch an executable option

To remove a registry entry I wrote a installscript code,

export prototype DeleteRegistryParameters(HWND);

function DeleteRegistryParameters(hMSI)
    // To Do:  Declare local variables. 
begin

    // To Do:  Write script that will be executed when MyFunction is called.

    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    SprintfBox(WARNING, "SetRegistryParameters", "Bye from internal", 0);

    ret = RegDBDeleteKey("XYZ");
    if (ret < 0) then
        formatStr = "RegSetValue failed with ret: 0x%x";
        SprintfBox(WARNING, "SetRegistryParameters", formatStr, ret);
    endif;  
    return ret;
end;

Here is sequence of all actions

1. Create a registry entry using installscript 
    Install Execute Sequence = After CostFinalize
    Install Execute Condition: "Not INSTALLED"
2. Install Service
    Install Execute Sequence = After SetRegistryParameters
    Install Execute Condition: "Not INSTALLED"
3. Start Service 
    Install Execute Sequence = After Install Service
    Install Execute Condition: "NOT Installed"
4. Stop Service 
    Install Execute Sequence = After InstallFiles
    Install Execute Condition: Remove = "ALL"
5. Remove Service
    Install Execute Sequence = After Stop Service
    Install Execute Condition: Remove = "ALL"
6. Remove Registry
    Install Execute Sequence = After Remove Service
    Install Execute Condition: Remove = "ALL"

But the package is not getting uninstalled and

Upvotes: 0

Views: 193

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55620

A service is a service is a service. Doesn't matter if it's C++, C#, Java, .PL, .PY using ServAny.exe or whatever. Windows Installer's ServiceInstall and ServiceControl tables can handle it. The Registry table handles Registry. InstallShield authores MSI's. In other words, ditch the custom actions and get rollback / uninstall for free.

See: Zataoca: Custom actions are (generally) an admission of failure.

a. The setup developer wrote a custom action that was already supported by the underlying engine. This is essentially reinventing the wheel with a less stable solution. Invariably this comes down to lack of documentation or lack of effort on the developer's part. Either way a failure to use the most optimal solution.

Upvotes: 1

Related Questions