MidnightJava
17th June 2007 06:07 UTC
servicelib doesn't work with uninstall functions
I'm following the instructions for using servicelib, but the !define doesn't seem to get defined, for some reason.
From an uninstaller section, I call the following function:
Function un.uninstallServices
!undef UN
!define UN ".un"
#if client service running, stop it
!insertmacro SERVICE "running" "rcb_Client" "action=stop;"
FunctionEnd
But I get the following error on the !insertmacro line above:
Call must be used with function names starting with "un." in the uninstall section.
Usage: Call function_name | [:label_name]
Error in macro SERVICE on macroline 4
Error in script "C:\Documents and Settings\Mark\My Documents\Eclipse\RemoteClipBoard\rcb_setup.nsi" on line 469 -- aborting creation process
And by looking at line 4 of the SERVICE macro in servicelib.nsh
!macro SERVICE ACTION NAME PARAM
Push '${ACTION}'
Push '${NAME}'
Push '${PARAM}'
Call ${UN}Service <-- blows up here
!macroend
It would appear that the !define had no effect.
What am I missing??
Afrow UK
17th June 2007 09:17 UTC
You should do it like this:
!macro SERVICE UN ACTION NAME PARAM
Push '${ACTION}'
Push '${NAME}'
Push '${PARAM}'
Call ${UN}Service
!macroend
!insertmacro SERVICE "un." "running" "rcb_Client" "action=stop;"
!insertmacro SERVICE "" "running" "rcb_Client" "action=stop;"
Stu
kichik
17th June 2007 20:08 UTC
The correct usage is actually:
Push "action"
Push "name"
Push "param"
Call un.Service
Pop $0 ;response
MidnightJava
17th June 2007 20:28 UTC
The servicelib documentation mentions two methods, equivalent to what Kichik and Afrow UK have suggested. However, the instructions in the comments of servicelib.nsh for invoking from the uninstaller seem to be incorrect.
For method 1 (Kichik's post) the instructions say to call Service (not un.Service), and the call to un.Service or Service is handled internal to Service, depending on the defined value of UN. Likewise with method 2, there is no UN parameter when inserting the macro SERVICE, and the define for UN is used instead.
Does the documentation for servicelib (and the change to SERVICE to add the UN parameter) need to be corrected? I'm using Version 1.4 Dec 7 2006, which was what I found by searching this site.
Also is there some scope rule for defines being violated the way I attempted to run this? It seems that using !define UN should have worked.
Thanks for your help. The script is working as needed.
-Mark