Archive: Uninstall info and MultiUser.nsh


Uninstall info and MultiUser.nsh
Having read MultiUser/readme.html until I'm blue in the face, I still can't work out how one is supposed to get an installer to set up uninstall info in the registry ... HKCU for a 'current user 'install and HKLM for an 'all users' install. The documentation barely touches on what one might need to do in an uninstall script.

At least, this seems to be handled automatically for $INSTDIR, but what I'm trying to do is to get the startmenu folder name selected by the user during install -- commonly known as $ICONS_GROUP -- so that I can delete the shortcuts to the application during uninstall.

I'm aware of the bug in which HKLM and HKCU are transposed, that's not the problem.

Is there a worked example anywhere showing how to put MultiUser.nsh through its paces for both install and uninstall?


Re: Uninstall info and MultiUser.nsh

Originally posted by Daniel James
... this seems to be handled automatically for $INSTDIR ...
Oh, no, it isn't. $INSTDIR is just getting set to the directory from which uninst.exe is run ...

The installer contains the following definitions and section:

!define PRODUCT_NAME "My Application"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

...

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\VA32.EXE"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\MyApp.EXE"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

... which works when the installer is run by an administrator, but because it uses HKLM) not when run by a normal user. How do I rewrite this using MultiUser.nsh?

Once I have that working it should be trivial to store the $ICONS_GROUP string in the registry as well, so I can recover it during uninstall.

It looks as though MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY and MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME are what I need here ... but I have no idea how to use them.

http://forums.winamp.com/showthread.php?threadid=288468


Originally posted by Joost Verburg
http://forums.winamp.com/showthread.php?threadid=288468
Well, yes, thanks ... but I did search the forums and I have read that thread several times.

I presume one sets up definitions like these:

!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallLocation"

(or something similar ... and does one need an extra '\\' at the end of the key?)

... but what then? How exactly does MultiUser.nsh use these values? How can I make use of this mechanism in my script to manage different values under the same (or a different) key?

I have been trying to follow the source of MultiUer.nsh to see just what it does, but NSIS script language isn't the most readable language in the world (especially to a relative beginner).

Googling for "MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY" produces precisely two hits, one to the MultiUser readme file and one to a boardreader.com page that doesn't appear to contain that string ... the web knows of no other documentation and no examples. How does one use this feature?

Inquiring minds are keen to learn.

For the uninstall info use SHELL_CONTEXT instead of HKLM. In addition, add the /CurrentUser or /AllUsers command-line switch to your uninstaller location.

You also need to set MULTIUSER_INSTALLMODE_COMMANDLINE.