bostko
30th November 2010 10:24 UTC
Read dynamically uninstall Name
I'm reading on startup .onInit the $my_name variable and
Name $pdName
This works great for my installer but what if I want to use it for the uninstaller
Can you tell me how exactly NSIS is generating variables for the uninstaller. Is there some way to store them on WriteUninstaller
T.Slappy
30th November 2010 15:24 UTC
Do you mean the OutFile ???
Because there is a difference between Name and OutFile.
Name - it is just a description of installer, just some string
where the OutFile is name of the .exe file written to disk
WriteInstaller has nothing with them - it is a name of .exe file written to disk which is used to uninstall your application - you can name if freely
bostko
30th November 2010 16:24 UTC
All I'm saying is that it is easy to declare in the nsi head
Name My Program
but when it is
Name $varSetOnInit
It has to be variable which is set .onInit or respectively in un.onInit
Is there any chance to store its value on this row
WriteUninstaller $INSTDIR\uninstaller.exe not on compile time
blh83
30th November 2010 18:07 UTC
This may not be what you are looking for but you can store the value in the registry. For example, in one of my installers I have the "-Post" section write values out to the registry. You could also do this just before, or after, you execute the write uninstaller command. Here's an example from my "-Post" section:
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
You can then simply read this variable in the uninstaller by using ReadRegStr and either store it in a variable you created or simply store it in a stack variable and use it:
ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
Now do a StrCmp on $0 to "" or do ${IF} $0 != "". You may also want to check the error flag (see the documentation on ReadRegStr about what the error flag will be set to). Hope this helps.