Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 26th March 2008, 16:59   #1
Daniel James
Junior Member
 
Join Date: Feb 2008
Location: Near London, UK
Posts: 40
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?

Cheers,
Daniel
Daniel James is offline   Reply With Quote
Old 27th March 2008, 10:35   #2
Daniel James
Junior Member
 
Join Date: Feb 2008
Location: Near London, UK
Posts: 40
Re: Uninstall info and MultiUser.nsh

Quote:
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:
code:

!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.

Cheers,
Daniel
Daniel James is offline   Reply With Quote
Old 27th March 2008, 15:54   #3
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
http://forums.winamp.com/showthread.php?threadid=288468
Joost Verburg is offline   Reply With Quote
Old 27th March 2008, 17:54   #4
Daniel James
Junior Member
 
Join Date: Feb 2008
Location: Near London, UK
Posts: 40
Quote:
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:
code:

!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.

Cheers,
Daniel
Daniel James is offline   Reply With Quote
Old 29th March 2008, 13:56   #5
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
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.
Joost Verburg is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump