Archive: Clever installer - administrator/limited user


Clever installer - administrator/limited user
Is it possible to make an installer which can check permissions of user and make installation in HKLM or HKCU?

E.g. how to make InstallDirRegKey sensitive to current permissions? If user can, installer can use InstallationPath in the HKLM, otherwise put it in the HKCU.

Is it possilbe?


I am not sure, but SHCTX from Manual, F.7 2.06 does this in gegistry instructions. May be this also works with attributes?


But how to call it before InstallDirRegKey?
Seems the SetShellVarContext must be in section only:
Error: command SetShellVarContext not valid outside section or function
Or is it possible to put InstallDirRegKey in section?
And also I wanna set SetShellVarContext to 'all' only if admin privileges. Is it possible?


InstallDirRegKey if first requested on 'dir' page, while Context might be defined on .onInit function. But I tested InstallDirRegKey attribute parameters and it looks like SHCTX is not accepted. So you need a bit more programming - read $INSTDIR string from HKLM or HKCU depending on the current context (if registry value exists). Few lines of code only ;)


It works! Thanks!
But InstallDirRegKey seems useless in this situation.


correct ;), feel fee to improve the NSIS source to improve the behaviour...


"fee" or "free"? :)
Actually I am not sure how to improve... SetShellVarContext is also function-level stuff, and it is meanless to add SHCTX support for InstallDirRegKey.


I suppose the solution can be something like this:
To allow multiple InstallDirRegKey directives, and it will check registry for a first existing key, install path will be amended to it.

In this case you can write
InstallDirRegKey HKLM ...
InstallDirRegKey HKCU ...

What do you think? Does it make sense?