Archive: Home directory when escalating privileges


Home directory when escalating privileges
Hi,

I have a problem: if an user runs an installer as a guest it'll ask for the admin password and gain privileges. The problem is that then $HOMEDRIVE and $HOMEPATH will return the information relative to the admin, not the original user.

How can I get around this?

Thanks.


The proper way to do this consists of two steps:
In the installer:
- Copy the required files to all user appdata ($LOCALAPPDATA after setshellvarcontext all)
In your application:
- Copy the files from alluser appdata to the applicable currentuser directory when the application is run for the first time at userlevel.

On a tangential note: Why do you want the contents of $HOMEPATH? You're not supposed to write to hardcoded paths like $HOMEPATH\foo\bar. You should write to appdata instead.


Originally posted by MSG
The proper way to do this consists of two steps:
In the installer:
- Copy the required files to all user appdata ($LOCALAPPDATA after setshellvarcontext all)
In your application:
- Copy the files from alluser appdata to the applicable currentuser directory when the application is run for the first time at userlevel.
Uhm, I'd prefer to avoid that - introducing logic in the application for something that should be taken care of in the installer is kind of ugly. Is there any other way?

On a tangential note: Why do you want the contents of $HOMEPATH? You're not supposed to write to hardcoded paths like $HOMEPATH\foo\bar. You should write to appdata instead.
This doesn't really depend on us, we're writing an Erlang application and the cookie has to be put in the home dir.

The other solution is to install without elevation to somewhere in the users profile ($localappdata\programs) and write the registry details to HKCU. (Single user aka "Just Me" install)

The reason you should install the initial application state to the all users profile or programfiles and copy it out on first run is because the basic scheme of storing it directly in the users profile during install breaks down when another user on the same machine tries to run the application, they will not get any state since they cannot (and should not) access the "first" users profile.