Archive: Calling a custom plugin from the Uninstall section fails


Calling a custom plugin from the Uninstall section fails
Hello everyone. I've created a custom C++ plugin to perform certain specialized tasks during the install and uninstall. The plugin currently has two functions, one called from the main installation section, the other called from the Uninstall section. Calling the function from the main section works like a charm. However, when I call the cleanup function from the Uninstall section the code never executes. The script compiles fine and uninstall completes successfully but the uninstaller doesn't attempt to execute the cleanup function from the plugin. I am using the latest development snapshot. Here's a piece of code from my script:

Section Uninstall
; Uninstall the trigger
InstallHelper::CleanupFunc ; <--- this never executes

Delete "$INSTDIR\${PRODUCT_NAME}.url" ; <--- this executes fine
; ..........
SectionEnd


Plug-ins in uninstaller sections should work fine. Are you sure there is no bug in your code?


Although one can never be 100% sure, however it is a rather simple example... I have a plugin with a TestFunction that displays a message box on entry. When I call TestFunction from the main section the message box displays fine. When I call it from Uninstall, it simply does not display. All other code in Uninstall executes (native NSIS functions). I removed all other code just to see if this works, and it fails. I do not have any conditional code in my script...


Works fine for me. Using the NSIS latest version? Can you post an example with plug-in and source?


I used the latest development snapshot (downloaded it yesterday). I attach the code for the installer to this post. There's nothing special about the plugin, especially considering that the same function is called from the main section perfectly fine. Perhaps the plugin is "removed" by the uninstall script before it tries to call it?


The plug-in is bundled inside the uninstaller data block, it can't be removed. How do you test that the plug-in has not been called?


Well, the function does some cleanup in the database and when I check the db the cleanup has never occured. It does clean up the database when I call it from the main section. After a while I just started popping up message box on entry.

The plugin dll uses one of the dlls I install (DBHelper.dll). Perhaps the function isn't called because I remove DBHelper.dll before I call the the plugin? I tried to move the call to the plugin above the "Delete" commands but it doesn't seem to have any effect.


Make sure all the DLLs that plug-in depends on are in somewhere the loader can find them. The best place is the current working directory which is set using SetOutPath.


Could you please give a little more information? Do you mean at the time I compile the install script or during the actual runtime of install/uninstall on a target machine?


If you DLL files depend on other files, make sure that the loader can find them.

If you store these files in the current folder (which you can set using SetOutPath), the loader will find them.


Placing a SetOutPath in the uninstall section and setting it to the $INSTDIR worked like a charm. Thank you very much for your help. NSIS is an amazing piece of software. I am doing some custom work for managing COM+ applications through NSIS (creating a COM+ application, installing a component, etc.) and when I have time I'll try to donate the code. Keep up the good work!