Archive: Pass a variable value to uninstall.exe


Pass a variable value to uninstall.exe
  During the Installation I assign a value to a variable:

StrCpy $1 "blah"

When I perform later an uninstall I want to access this
variable content but it is empty.

How could I pass such a value?

Alternatively I assumed that it is possible to pass a value through the command line (as a parameter).

But when I coded and called a link

uninstall /DBLAH=XXX

and inside the script:
!ifndef BLAH
!define BLAH "AAA"
!endif
...
Section "Uninstall"
...
MessageBox MB_OK "BLAH=${BLAH}"
...
SectionEnd

..I got a window popup saying:
BLAH=AAA
and not as desired:
BLAH=XXX

Why?


I recommend you that you use the "!define"

When you use, for example:


!define Name "Dude"

Everytime that use put ${Name}, the compiler will replace it with
"Dude", even in the Uninstaller Section.

The /D switch is for makensis.exe not the generated installer. The installer supports only the /S and /NCRC command line switches. You should just pass the parameter as it is without any command line switches and then read it from $CMDLINE in the uninstaller. To get the parameters from the command line use GetParameters. Be aware though that if the user double clicks on your installer in Windows this parameter will not pass, therefore it might be a better idea to save this in the registry.


Hmmm, all the GetParameter variant doe not work:

If I call uninstall with a paramter and try to
call GetParameter the compilation of the NSIS script yields:

"Call must be used with function names starting with "un." in the uninstall section."

On the other side I cannot code unGetParameters in the Uninstall Section


Well, as the error says the function name must start with "un.". Just add the "un." prefix to the function name - un.GetParameters. Also call it with this name - Call un.GetParameters.


This is exactly what I have done. Below you will find the exact line from my script:

Call un.GetParameters

But I got from the compilation process:

Processed 1 file, writing output:
Error: resolving uninstall function "un.GetParameters" in "uninstall section"
Note: uninstall functions must begin with "un.", and install functions must not
Error - aborting creation process

So what more can I do ??


The compiled script generates two programs: the installer and the uninstaller. The compiler needs to know which functions, sections and page-instructions belong to the installer, and which belong to the uninstaller.
Functions that belong to the uninstaller have "un." before their name:


GetParameters

FunctionEnd
>
To call such a function, use:

Call un.GetParameters 

>
So you propably forgot to change the function's name to "un.GetParameters".

If I understand it right the function
GetParameters
is available as a NSIS built-in function in the compiler
whereas the function
un.GetParameters
is NOT a built-in function.

So I have to
- search for the original source of GetParameter somewhere in the
NSIS installation,
- then cut & paste it to my own source,
- prepend an "un." and
- recompile it.
Is this you want to suggest ?

Hmmm, very unconvenient.


That would be because you misunderstand :)

GetParameters is NOT a built-in function, it is merely a function that is in appendix B of the documentation. Therefore it is a normal function like any other, if you want it in the uninstaller it needs un. in the name.

I think it's about time we had a new prefix for functions, something like both.funcname.


those, you need to think simple. NSIS is simple too. ;)

- GetParmeters is a function, as described in Appendix B, Section 3.
- un.GetParameters is the same function, but with un. in front of it's name. un.GetParameters is available to the uninstaller, not to the installer, while GetParameters is available to the installer ONLY.

To make your script working, just paste the source of the GetParameters-function into your script (if you haven't already), and change the function's name to 'un.GetParameters'.