User profiles and HKEY_CURRENT_USER - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

User profiles and HKEY_CURRENT_USER

Hi,

I am creating few users using my installer. I want to put some thing by default in every user's profile and HKEY_CURRENT_USER reg paths. How can I do that?

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: User profiles and HKEY_CURRENT_USER

Hello,

I am afraid this is not possible nor recommended. An installer can either set a "per-machine" registry key in HKEY_LOCAL_MACHINE or a per-user key in HKEY_CURRENT_USER which is different for each user that is logged on.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

Re: User profiles and HKEY_CURRENT_USER

Hi Gabriel,

Few things can only been done on HKEY_CURRENT_USER (for eaxmple switching off the security warning when running exe's from a mapped drive). The installer is creating the users. So the installer type, I think, must be per machine. Isn't there a work around for this?

How about the USERPROFILE. Again I want to add files to all the users' USERPROFILE I am creating from my installer.

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: User profiles and HKEY_CURRENT_USER

Hello,

I am afraid I am aware of no workaround for this. The HKEY_CURRENT_USER subtree is stored in ntuser.dat which is user-specific. This subtree is only loaded for the
currently logged user. There is no way I know of to access the HKEY_CURRENT_USER of another user.

You could however place your settings in HKEY_LOCAL_MACHINE, then instruct your application to read them from that location and apply them to the current user.
How about the USERPROFILE. Again I want to add files to all the users' USERPROFILE I am creating from my installer.
To achieve this you could:
- extract the value of the [%USERPROFILE] environment variable. This would evaluate to the folder of the current user (say: c:\documents and settings\alfred)
- obtain the parent directory of the above path (this would be c:\documents and settings)
- use the usernames of the users you are creating to append them to this directory. If the username you are creating is testuser then append it to the above path, thus obtaining c:\documents and settings\testuser
- write your files here
- repeat the above steps for each user you are creating

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

Re: User profiles and HKEY_CURRENT_USER

Hi Gabriel,

Thanks. I have not tried your solution as I was away for some time. I will implement your suggestion.
srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

Re: User profiles and HKEY_CURRENT_USER

Hi Gabriel,
The following did not work out:
To achieve this you could:
- extract the value of the [%USERPROFILE] environment variable. This would evaluate to the folder of the current user (say: c:\documents and settings\alfred)
- obtain the parent directory of the above path (this would be c:\documents and settings)
- use the usernames of the users you are creating to append them to this directory. If the username you are creating is testuser then append it to the above path, thus obtaining c:\documents and settings\testuser
- write your files here
- repeat the above steps for each user you are creating
If I do the above, Windows creates another directory with the name <username>.<machinename> and make it as the %USERPROFILE% for the user and never touches the directory created by the installer.

Any other work arounds?

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: User profiles and HKEY_CURRENT_USER

Hello,

I am not sure I understand what is happening. Could you please describe the problem in more detail?

Thank you,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

Re: User profiles and HKEY_CURRENT_USER

Hi Gabriel,

This is what I am doing.

During installation phase, I extract the %USERPROFILE% value
Obtain the parent directory (this is C:\Documents and Settings)
Create a directory there named after the user I am creating (for example C:\Documents and Settings\MyUsername)
Create the files I want to be in the User's profile

With the above a directory C:\Documents and Settings\MyUsername is successfully created. But after installation, when I log on as the created user the directory 'C:\Documents and Settings\MyUsername' is completely ignored; but a new directory 'C:\Documents and Settings\MyUsername.MyMachineName' is created and that is used as the USERPROFILE.

Fortunately, I have found a work around for this. What I do is I create the file, that should be present in all the users' profile, in '%USERPROFILE%\..\Default User'. This is used as the template for a new user profile and everything under '%USERPROFILE%\..\Default User' is copied to the 'Documents and Settings' of the new user created.

So, this is sorted now. The only problem now is this HKEY_CURRENT_USER.

Thanks
srini
Posts: 81
Joined: Mon Sep 14, 2009 4:22 pm

Re: User profiles and HKEY_CURRENT_USER

Hello,

I have found a work around for this as well.

I have written a vbscript and execut it during the installation phase. This vbscript would temporarily load the hive, 'Defaul User''s NTUSER.DAT into the registry and add the needed entries into it. So after a user is created and the user logs on, this NTUSER.DAT is copied as the default HKEY_CURRENT_USER. After making the changes, the script will unload the hive.

Regards

Return to “Common Problems”