I want to write a application that writes to all users on a local machine a specified key (eg: i want set the location for IE Favorites for all users to the same folder)
PS
anybody used these functions?
LoadUserProfile
RegOpenCurrentUser
CreateProcessAsUser
I’ve done this many times. The idea is to update the currently logged on user’s HKCU (that’s easy enough). Then you must enumerate every profile on the system and find their ntuser.dat file (that’s easy enough too).
With the ntuser.dat file found, you load it into a temporary key in the HKLM hive (I usually use ‘HKLM\TempHive’. Then edit away.
If there is more than 1 user logged on, their profile will be loaded under HKEY_USERS, by their SID. Simply update that location.
To modify the setting for any new users, simply modify the appropriate key under HKEY_USERS.DEFAULT, OR use the Delphi code below which will do this by loading the Default Users’s HKCU registry hive (stored in ntuser.dat).
UPDATE: I found my Delphi code that demonstrates how to update the HKCU hives of users that are not logged onto the system.
This requires Russell Libby’s ‘Privilege’ component, which is available here.
I also wrote a VBScript a while ago that accomplishes this task. I used it for modifying some Internet Explorer settings, but you can customize it to your needs. It also demonstrates the general process: