Run custom uninstaller for a DotNetInstaller generated EXE

163 Views Asked by At

I have a msi installer wrapped into a DotNetInstaller exe file. Everything works fine but when I try to uninstall it from the Add/Remove window it doesn't run the .exe file but the .msi. I really need the .exe to be run because I'm passing properties' values as uninstall_cmdparameters. Please Help.

Thanks in advance.

1

There are 1 best solutions below

0
On

OK, after struggling for like 4 days with this bullsh*t, I've finally came up with something.
I run a C# Custom Action before the install finalization and then I update the registry keys in Uninstall[ProductCode]:

string UNINSTALL_REGKEY = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"; string productCode = session["ProductCode"];

Registry.SetValue(UNINSTALL_REGKEY + productCode, "UninstallString", "MsiExec.exe /x " + productCode + " DELFILES=TRUE", RegistryValueKind.String);
Registry.SetValue(UNINSTALL_REGKEY + productCode, "WindowsInstaller", 0, RegistryValueKind.DWord);
(Note: the WindowsInstaller's value must be set to 0 otherwise it won't use the UninstallString's value)

Now when I remove my product from the Add/Remove Programs the uninstallation runs with my modified UninstallString.

Hope it helps to others with the same problem.