Old 14th October 2010, 15:49   #1
mabian
Junior Member
 
Join Date: Apr 2008
Posts: 30
Question 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
mabian is offline   Reply With Quote
Old 14th October 2010, 15:56   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
First link on Google search if you search for your topic subject + NSIS:
http://nsis.sourceforge.net/Sharing_...nd_Uninstaller

Please do a search in future.

Stu
Afrow UK is offline   Reply With Quote
Old 14th October 2010, 15:58   #3
mabian
Junior Member
 
Join Date: Apr 2008
Posts: 30
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
mabian is offline   Reply With Quote
Old 14th October 2010, 17:24   #4
redxii
Senior Member
 
Join Date: Nov 2005
Posts: 115
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.
redxii is offline   Reply With Quote
Old 14th October 2010, 17:26   #5
mabian
Junior Member
 
Join Date: Apr 2008
Posts: 30
Aaahhh now I get it, thanks!

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

This forum rocks

- Mario
mabian is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump