Archive: Uninstall with MultiUser.nsh


Uninstall with MultiUser.nsh
Hi.

I'm fairly new to NSIS, so I might be missing a trick, but I've checked the forums, the interweb, etc and I can't find an answer. I'm running NSIS 2.35 and I just played with the MultiUser options. By using MULTIUSER_PAGE_INSTALLMODE I can ask the user where he wants to install my application to. But the uninstall doesn't work properly. If I use MULTIUSER_INSTALLMODE_COMMANDLINE then the uninstall works perfectly for All User installations, but it doesn't work for Current User. And if I use MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER it's the opposite: it works fine for the current user, but not for all users.

Any ideas?

Glib


Is it the same as the following?

http://sourceforge.net/tracker/index...49&atid=373085


No, it's not related to that bug.

The uninstaller should know whether the application it's linked to is installed for the current user or for all users. Note that a system-wide and current-user version may be installed at the same time.

A simple solution is to add the /CurrentUser or /AllUsers command-line switch to your uninstaller location for the Windows Add/Remove programs control panel.


I'm having similar troubles on uninstall with multiuser.nsh...

I don't have MULTIUSER_INSTALLMODE_COMMANDLINE or MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER defined, but the uninstaller always runs in 'current' context when installed for AllUsers, in 'all' context when installed for current user.

@kichik: the bug you link to is noted as fixed, but the current code (2.35) still appears as Ivan described. do we need to implement his fix ourselves until the next release?

I've tried swapping these around, and it doesn't seem to have any affect?


After throwing messageboxes into each macro to see if it fires, I'm noticing that things are breaking somewhere in MULTIUSER_INIT_CHECKS Un un., and it's never calling the MULTIUSER_INSTALLMODE_ALLUSERS/CURRENTUSER macros where SetShallVarContext is set.


Hmm. These are always undefined (install *and* uninstall)...

!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME

Are these *designed* to be different values than the MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME ?


Okay, my problem is fixed with these steps:

1) Implement Ivan's suggestion, swapping the CurrentUser/AllUsers at lines 256 and 264 of NSIS 2.35's MultiUser.nsh

2) add two lines as follows into my script:
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"

Thanks for letting me post to myself. Hopefully someone else finds this useful. ;)


For the uninstaller I would recommend you to also implement what I suggested in my previous post. A registry key won't work for uninstallation if both a per-user as well as a per-machine installation exists.


Thanks. Is this switch added to the UninstallString registry value? Or somewhere else?


Yes, that's right. You also need to set MULTIUSER_INSTALLMODE_COMMANDLINE.