Archive: HKCU & RunAs


HKCU & RunAs
In my installer I am using HKCU to store user settings, however when installed with RunAs (Administrator) the HKCU settings go to Admin instead of the actual user logged in.
Is there any way to push the registry settings to the logged in user?
How do I determine the logged in user's name?

In some corporate settings which are very restrictive the app must be installed this way to function, but all the HKCU entries end up in the wrong user's sub-tree.

Thanks


Anyone have any thoughts?


Hi,

HKEY_CURRENT_USER is actually a shortcut to HKEY_USERS\{id-of-the-current-user} so you should search a way to get the id of the user logged in.

Hope this helps :)


I guess this is really a slightly different question:
If using run-as as admin, how do I find out the user logged in is actually bob? (or how to let NSIS know this)


Retrieving the users sid won't help you at all.

You should make 2 scripts. The first installs the app. The second script is the starter script for the users. it checks if the neccessary reg key exists and create them if necceassary.

This way the app will work for users who never worked with the machine and thus have no profile yet.


Hmm...
That seems to be a better idea. :)
Much simpler too.
Thanks flizebogen!

Why do I always seek the spoon when digging tunnels...


We are going to have the installer make a .reg file and then the user can run the reg script once and then have all the settings.
The paths need to have double backslashes \\ in order to import.
I tried the INI writing functions in NSIS but none worked for this.
What's the easiest way to get a string with double \\ from $INSTDIR ?