Load a User's Hive Programmatically 
Author Message
 Load a User's Hive Programmatically

I have a program that will list all the user's accounts on a NT
system --could be a local NT system or a remote NT system. Based on the user
accounts the operator of the program can then pick a user from the list of
accounts to make modifications to their registry. This means the program
will need to dynamically load the accounts hive programmatically. What is
the best way to do this? I looked at the APIs LogonUser and
CreateProcessAsUser. I have noted that LogonUser will fail if the system is
a remote system.

I did find the article within the MSDN entitled, "Load a User's Hive
Programmatically" within the MSDN. Unfortunately the examples are all in C
making it hard to read for this VB only programmer. Can anyone shed some
light on the best path forward to accomplish the aforementioned goal or have
some code samples in VB for loading a User's hive programmatically?

Thanks!

JR



Fri, 09 Aug 2002 03:00:00 GMT  
 Load a User's Hive Programmatically
Bjorn,

Thanks for getting back to me!

I read a bit about your suggestion and I was wondering....wouldn't
RegOpenCurrentUser be a more logical choice? RegRestoreKey seems to be a bit
more dangerous in that in copies registry information wholesale into a
specified key. There really is no way to use it in a surgical sense. But
ultimately, neither RegRestoreKey or RegOpenCurrentUser are supported in
NT4.

Thanks!

Jerry Rawdon


Quote:
> Jerald,

> Load the user hive file into the local registry using the RegRestoreKey
api.
> Make your changes, then use RegSaveKey to write the hive to the hive file.

> Unfortunately, I have no sample code using those api's, but if you like, I
> can
> prepare some for you. Let me know.

> Bj?rn Holmgren
> Framfag/Guide AB



> > I have a program that will list all the user's accounts on a NT
> > system --could be a local NT system or a remote NT system. Based on the
> user
> > accounts the operator of the program can then pick a user from the list
of
> > accounts to make modifications to their registry. This means the program
> > will need to dynamically load the accounts hive programmatically. What
is
> > the best way to do this? I looked at the APIs LogonUser and
> > CreateProcessAsUser. I have noted that LogonUser will fail if the system
> is
> > a remote system.

> > I did find the article within the MSDN entitled, "Load a User's Hive
> > Programmatically" within the MSDN. Unfortunately the examples are all in
C
> > making it hard to read for this VB only programmer. Can anyone shed some
> > light on the best path forward to accomplish the aforementioned goal or
> have
> > some code samples in VB for loading a User's hive programmatically?

> > Thanks!

> > JR



Sat, 10 Aug 2002 03:00:00 GMT  
 Load a User's Hive Programmatically
Jerald,

Load the user hive file into the local registry using the RegRestoreKey api.
Make your changes, then use RegSaveKey to write the hive to the hive file.

Unfortunately, I have no sample code using those api's, but if you like, I
can
prepare some for you. Let me know.

Bj?rn Holmgren
Framfag/Guide AB



Quote:
> I have a program that will list all the user's accounts on a NT
> system --could be a local NT system or a remote NT system. Based on the
user
> accounts the operator of the program can then pick a user from the list of
> accounts to make modifications to their registry. This means the program
> will need to dynamically load the accounts hive programmatically. What is
> the best way to do this? I looked at the APIs LogonUser and
> CreateProcessAsUser. I have noted that LogonUser will fail if the system
is
> a remote system.

> I did find the article within the MSDN entitled, "Load a User's Hive
> Programmatically" within the MSDN. Unfortunately the examples are all in C
> making it hard to read for this VB only programmer. Can anyone shed some
> light on the best path forward to accomplish the aforementioned goal or
have
> some code samples in VB for loading a User's hive programmatically?

> Thanks!

> JR



Sun, 11 Aug 2002 03:00:00 GMT  
 Load a User's Hive Programmatically



Quote:
> Bjorn,

> Thanks for getting back to me!

> I read a bit about your suggestion and I was wondering....wouldn't
> RegOpenCurrentUser be a more logical choice? RegRestoreKey seems to be a
bit
> more dangerous in that in copies registry information wholesale into a
> specified key. There really is no way to use it in a surgical sense. But
> ultimately, neither RegRestoreKey or RegOpenCurrentUser are supported in
> NT4.

Not booted into NT right now, I couldn't tell you for sure, but MSDN says
that RegRestoreKey works in NT3.1+, and as for RegOpenCurrentUser, it isn't
listed at all.

HTH
Stephen



Tue, 13 Aug 2002 03:00:00 GMT  
 Load a User's Hive Programmatically
Stephen,

RegOpenCurrentUser is listed in the latest version of MSDN. It is only
supported under Win2K.

Jerry


Quote:



> > Bjorn,

> > Thanks for getting back to me!

> > I read a bit about your suggestion and I was wondering....wouldn't
> > RegOpenCurrentUser be a more logical choice? RegRestoreKey seems to be a
> bit
> > more dangerous in that in copies registry information wholesale into a
> > specified key. There really is no way to use it in a surgical sense. But
> > ultimately, neither RegRestoreKey or RegOpenCurrentUser are supported in
> > NT4.

> Not booted into NT right now, I couldn't tell you for sure, but MSDN says
> that RegRestoreKey works in NT3.1+, and as for RegOpenCurrentUser, it
isn't
> listed at all.

> HTH
> Stephen



Fri, 16 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Load a User's Hive Programmatically

2. Load a User's Hive Programmatically

3. Load NT4 User Hive Programmatically

4. Load NT4 User Hive Programmatically

5. How to load the Default User Profile hive in HKEY_USERS

6. load registry hive to HKEY_LOCAL_MACHINE

7. Loading a registry hive in VBScript

8. Loading registry hives

9. Loading Registry Hives

10. Registry LoadKey to load hives?

11. COM+ Programmatically changing user's security context

12. Programmatically kill user connection/log user off server.

 

 
Powered by phpBB® Forum Software