Archive: Calling function from uninstall section


Calling function from uninstall section
The snippet below fails to compile because the function IsUserAdmin does not start with "un.".

IsUserAdmin was grabbed from http://nsis.sourceforge.net/archive/...php?pageid=275

What's the "recommended" way to address this problem?

Regards,
Angus


Section "Uninstall"
; Ascertain whether the user has sufficient privileges
; to uninstall.
SetShellVarContext current

ReadRegStr $0 "HKCU" "${PRODUCT_UNINST_KEY}" "RootKey"
StrCmp $0 "HKLM" 0 cont
Call IsUserAdmin
Pop $0
StrCmp $0 "true" user_is_admin user_is_not_admin
user_is_admin:
SetShellVarContext all
Goto cont
user_is_not_admin:
MessageBox MB_OK "Sorry! You must have administrator privileges$\r$\nto uninstall ${PRODUCT_NAME}."
Abort
cont:
SectionEnd


Sorry for replying to self, but I solved the problem by

!macro IsUserAdmin_private
!define skipBackupLbl "skipBackup_${__LINE__}"

; function body goes here

!undef skipBackupLbl
!macroend

Function IsUserAdmin
!insertmacro IsUserAdmin_private
FunctionEnd

Function un.IsUserAdmin
!insertmacro IsUserAdmin_private
FunctionEnd

Regards,
Angus