how to change the registry settings of another user

N

News123

Hi,



As part of a semi automatic installation and setup of a host I would
like to create one administrator account and one ore more (non
administrator) user accounts (without passwords)

Then I would like to start a script as administrator and change some
global and some user specific registry entries.

I have problems to modify the settings of another user whle being
administrator.

The registry entries don't exist). It seems I had to load some 'hive' to
be able to access somebody else's registry


I did my first tests not with C#, but with python and_winreg32,
but could switch for my above script


There are potentially at least two wo ways of doing this:

1.) start a sub process as other user and change the registry for
CURRENT_USER

However I don't know how to start a process (or ideally just a thread)
as another user under windows vista/7

2.) Load the 'hive' of the other user and change the registry.

It seems, that one has to load the 'hive' of a different user in order
to have access to somebody else's registry entries.

I don't know how to load a hive with the C# API.


Did anybody else try already something similar or have some pointers to
proceed?


thanks a lot in advance


N
 
P

Peter Duniho

News123 said:
[...]
1.) start a sub process as other user and change the registry for
CURRENT_USER

However I don't know how to start a process (or ideally just a thread)
as another user under windows vista/7

Have you tried using the System.Diagnostics.Process class, setting the
ProcessStartInfo.UserName property for the StartInfo object before
starting the process?
2.) Load the 'hive' of the other user and change the registry.

It seems, that one has to load the 'hive' of a different user in order
to have access to somebody else's registry entries.

I don't know how to load a hive with the C# API.

Me either. In the unmanaged API, it would be RegLoadKey(). But I don't
know of an equivalent in .NET.

You could, of course, use the unmanaged registry API via p/invoke. But
maybe the Process class will allow you to do what you want, by running a
small program to set the registry as you need under each user profile.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top