Archive: Install for all users or current user: Can NSIS help?


Install for all users or current user: Can NSIS help?
Hi,
Modern apps should allow the user to install, even without admin rights. A user with admin rights should be given the choice how to install. Depending on what choice the user makes the installer should write to HKEY_LOCAL_MACHINE or to HKEY_CURRENT_USER.

This is expecially important when dlls must be registered, because without admin rights the registration in HKEY_CLASSES_ROOT will usually fail. Instead of HKCR one should use either HKLM\Software\Classes or HKCU\Software\Classes.

Does NSIS provide any support for this?
Is there a page that asks this question or must I create one myself? Is there a standard variable to use during installation and uninstallation?

Cheers,
Joachim


I have seen some NSIS installers ask this question using a custom page designed with InstallOptions, but I do not beleive there is a built in page to ask this.


Use InstallOptions to create the dialog and depending on the radio buttons state, SetShellVarContext to all or current.

-Stu


Thanks for the answers.
I managed to create such a custom page, but of course the strings on this page will remain untranslated.

As for SetShellVarContext I found out, that this information must be saved somewhere, so that it is again available for the uninstall step. This variable I placed in the registry among my other app-settings. "HKCU/Software/Appname/InstalledForAllUsers".

By now it seems to work but I would still appreciate if original dialogs of NSIS could contain something of that kind.

Joachim


Hi,

I also need to use such a page in my script. Is there already an easier solution (standard page in NSIS, or a plug-in, or something else...)?


NSIS already permits this ability using the "MultiUser" header included. Take a look at:
http://nsis.sourceforge.net/Docs/MultiUser/Readme.html
http://nsis.sourceforge.net/Docs/MultiUser/Readme.html


Hi guys,
The MultiUser header solved my problem, but here it comes the next one (I don't know if this forum is suitable for such discussion). I have to deliver information to the applications that I installed what kind of installation is selected, because they also must access the corresponding registry area. What is the normal way to do this? I suppose that I have to write a registry value under HKLM that corresponds to the selection... Is this the right way?


You can use the registry, or write to an ini file in the app's directory, or whatever you prefer.

Of course if it's a single-user install, you can also use HKCU instead of HKLM.


If I write to HKCU by installation for the current user only, how the applications will know where to find this registry key (HKCU or HKLM)? Isn't correct to write such a common key always in HKLM? Depending on this key the applications can get information in which area they have to work. Sorry for the stupid questions, but I really don't have experience with this...


Like I said, you can use HKCU if it's a single-user install. If you want things to work the same for all users, then yes of course you have to use HKLM.