Archive: 1 Remaining Issue - Need Help


1 Remaining Issue - Need Help
All files in the package have a target folder location.
($INSTDIR}\blah\blah

The "administrative" files (shortcuts, uninst.exe, etc.) have a target of:

${programfiles}\${mui_product}

All files deploy to the proper locations.
Uninstallation fails, however. No files are removed from:

($INSTDIR}\blah\blah

And it says I'm trying to remove "Start Menu\Programs" which I am not.

Can someone please tell me what I'm doing wrong and how to get this to work?

According to the logic in the documentation, there is no reason why this should not work; unless the writing of the uninstallation is not "smart enough" to remember where files were placed on the building of the installation exe.

Sigh. I'm so close.


Why not use:


RMDir /r "$PROGRAMFILES\${MUI_PRODUCT}"

And...
Does the Uninstaller remembers the value for:
${MUI_STARTMENUPAGE_VARIABLE}
Doesn't this variable only for runtime during Intallation?
Maybe if you save the ${MUI_STARTMENUPAGE_VARIABLE} in the
registry then the uninstaller recover that value...

Haven't a clue about runtime.
Seems to me, the uninstaller should be written knowing where the user has chosen to install the files.

I wouldn't know how to write that value to the registry and call it later.


The StartMenu.nsi example shows you how to store it in the registry (using MUI defines).


Sorry, Joost.
I don't get how to apply what is in the example script to my script. That to me is one of the biggest problems with NSIS--examples between scripts don't "port" that well to other scripts.

I'm just not sure how to do it.


Yeah. This just doesn't make sense to me.
None of the files I've deployed are being deleted when the uninstallation section seems to be perfectly legal.

The Start Menu program group created is not getting deleted.

The ONLY thing being deleted correctly is the Program Files\${MUI_PRODUCT} folder and its contents.


Your $INSTDIR defauls to "$PROGRAMFILES\Forgotten Battles" (InstallDir command) but you are writing the uninstaller to "$PROGRAMFILES\${MUI_PRODUCT}" which is "$PROGRAMFILES\7JG77 Skin Pack". You should always use $INSTDIR. The uninstaller initializes $INSTDIR to the directory it lies in.

As for the start menu, this is the part of the example you need (notice the .lnk files deletion):

!insertmacro MUI_STARTMENU_DELETE_BEGIN ${TEMP}

Delete "$SMPROGRAMS\${TEMP}\Modern UI.lnk"
Delete "$SMPROGRAMS\${TEMP}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${TEMP}" ;Only if empty, so it won't delete other shortcuts

!insertmacro MUI_STARTMENU_DELETE_END

Ok. Thanks, Kichik.

Will the uninstaller remember or know what to substitute ${TEMP} with? Will it be able to pull the variable from installation MUI_STARTMENUPAGE_VARIABLE ($9) ?


As TEMP is a define, and is a compile time "variable" it will be "remembered" in the uninstaller too. Everytime the compiler sees ${TEMP} it just replaces it with its value, $9 in this case.

The value inside $9 will not stick to the uninstaller but this line:
!insertmacro MUI_STARTMENU_DELETE_BEGIN ${TEMP}
reads it from the registry for you.


When did it get written TO the registry?


In the MUI_STARTMENU_WRITE_BEGIN macro.


Nope, wrong one. It's in the MUI_STARTMENU_WRITE_END macro and only if MUI_STARTMENUPAGE_REGISTRY_ROOT, MUI_STARTMENUPAGE_REGISTRY_KEY and MUI_STARTMENUPAGE_REGISTRY_VALUENAME are defined. Define those and the MUI macros will take care of the writing and reading. You should still delete though.


Fix one thing, breaks another...
Kichik. This has all just made everything worse.
I define one thing, something else breaks. I fix that, and it breaks something else.

I'm getting the error:
!insertmacro: macro named "MUI_STARTMENU_DELETE_BEGIN" not found!

Can you look at this and tell me where I've screwed up?


!define MUI_STARTMENUPAGE
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${MUI_PRODUCT}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${MUI_PRODUCT}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "$9"


I have this before the language macro (which needs to be last)...

I use $9 because that is the variable that will hold the users' custom Start Menu group if they don't choose default, right??

How do I populate the MUI_STARTMENUPAGE_REGISTRY_VALUENAME without redefining the reserved variable $9 ??

If $9 contains the user's choice for SMPROGRAMS, then how do I populate that choice as a variable in MUI_STARTMENUPAGE_REGISTRY_VALUENAME without redefining the very same variable??


Right, that's an addition in the latest CVS version. Use:

;Remove shortcut
ReadRegStr ${TEMP} "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" "${MUI_STARTMENUPAGE_REGISTRY_KEY}" "${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}"

StrCmp ${TEMP} "" noshortcuts

Delete "$SMPROGRAMS\${TEMP}\Modern UI.lnk"
Delete "$SMPROGRAMS\${TEMP}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${TEMP}" ;Only if empty, so it won't delete other shortcuts

noshortcuts:


To remove the shortcuts (taken from the StartMenu.nsi example).

MUI_STARTMENUPAGE_REGISTRY_VALUENAME is $9. When you define MUI_STARTMENUPAGE_REGISTRY_VALUENAME as $9 the compiler just replaces every ${MUI_STARTMENUPAGE_REGISTRY_VALUENAME} with $9, that's all, it's not another variable. Its value is set after the start menu page shows.

No...
MUI_STARTMENUPAGE_VARIABLE is $9.
Not MUI_STARTMENUPAGE_REGISTRY_VALUENAME ??

What populates MUI_STARTMENUPAGE_REGISTRY_VALUENAME if the user chooses their own custom Registry entry?

How do I !define this variable without stepping on the toes of the MUI_STARTMENUPAGE_VARIABLE, which is $9 ?

I have to put SOMETHING in quotes after MUI_STARTMENUPAGE_REGISTRY_VALUENAME. Since I don't want to hardcode anything, I need that variable to write to the registry whatever the user chooses if the user does not choose my suggested default!


Besides, using your example, I get a new error:

Usage: ReadRegStr $(user_var: output) rootkey subkey entry
root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)


MUI_STARTMENUPAGE_REGISTRY_VALUENAME is the registry value name. It has nothing to do with MUI_STARTMENUPAGE_VARIABLE. It is not the value itself, just the name that identifies the value. You should name it something like "Start Menu Folder", just like in the example.


That's because you have not defined TEMP. Either use:

!define TEMP $R9

or replace every ${TEMP} with another variable.


Kichik.
Where do I donate $$ to WinAMP and NSIS?

My installer now works. I GREATLY appreciate your time in helping me through my frustration and learning curves.


Thanks, I'll check and let you know :)

Good luck with your installer.


As Winamp and NSIS are two different projects there is no one place to donate for both. To donate to Winamp you need to donate to Nullsoft and as for NSIS, I have sent you a PM with a mailing address.

Thanks