Skip to content
⌘ NSIS Forum Archive

Calling same function during install and uninstall

5 posts

mabian#

Calling same function during install and uninstall

Hello,

I know about the "un." limitation for uninstall function calls, but I wonder if there's some way to call the very same function during install and uninstall.

In particular, my function checks for the existence of a service; if exists, it stops it and removes it, so that:

- When installing, the updated service can be installed
- When uninstalling, the service can be removed

I'd like to reuse the same code portion and avoid macros (it's about thirty lines code using labels).

Is there some way to do this?

Thanks,
Mario
Afrow UK#
First link on Google search if you search for your topic subject + NSIS:


Please do a search in future.

Stu
mabian#
Thank you, I already found it; but with this technique, the code is actually doubled in the installer - so double room taken.

I was looking for a smarter solution... 🙂

- Mario
redxii#
You can't call a function in the installer from the uninstaller and vice versa, they are separate files.

So you have to use that macro technique to make it easier to maintain one piece of code for both or copy and paste the function adding "un." in front of the function name for the uninstaller.
mabian#
Aaahhh now I get it, thanks!

I used the "double macro" approach, works great.

This forum rocks 😉

- Mario