PDA

View Full Version : Clever installer - administrator/limited user


kan.izh
8th February 2006, 09:37
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?

Takhir
8th February 2006, 10:02
I am not sure, but SHCTX from Manual, F.7 2.06 does this in gegistry instructions. May be this also works with attributes?

kan.izh
8th February 2006, 13:37
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?

Takhir
8th February 2006, 15:02
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 ;)

kan.izh
8th February 2006, 18:22
It works! Thanks!
But InstallDirRegKey seems useless in this situation.

onad
9th February 2006, 10:39
correct ;), feel fee to improve the NSIS source to improve the behaviour...

kan.izh
9th February 2006, 11:11
"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.

kan.izh
9th February 2006, 13:30
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?