Archive: call IsUserAdmin in un.onInit ?


call IsUserAdmin in un.onInit ?
  I am trying to call IsUserAdmin (downloaded from http://nsis.sourceforge.net/IsUserAdmin ) in un.onInit, but I receive the following error:

Call must be used with function names starting with "un." in the uninstall section.
I tried wrapping IsUserAdmin with a !macro (based on the advice given in another thread here), but I still receive the same error.

The only option I see right now is to create another function, named un.IsUserAdmin, essentially duplicating the code of IsUserAdmin. However, this is ugly and I would prefer to find a more elegant solution.

Any ideas?

10 minutes later update: I just discovered this thread.

Hi nsnb,
It looks like you may have found the answer in the thread you found, but I'll summarize the gist of it here just in case it helps others:

Basically, you just need prefix uninstall function names with "un." (This is also outlined in the help files for the function command.)

The thread you found pointed out shows some more advanced ways you can do this using macros to make the process more "automatic", but the principle is basically the same.


Thank you, Comperio. You are correct in your observation that I already knew about the requirement for the prefix "un." for uninstall section functions. I just didn't know how to avoid code duplication. Thanks to that link I was able to accomplish what I wanted by simply surrounding IsUserAdmin as follows (it's in C:\Program Files\NSIS\Include\isuseradmin.nsh):

!macro macIsUserAdmin un

>Function ${un}IsUserAdmin
...
...
FunctionEnd
>!macroend
>!insertmacro macIsUserAdmin ""
>!insertmacro macIsUserAdmin "un."
This works like magic. Now I have two functions but only one piece of code to maintain or update. :)