View Full Version : Finding a way to access CURRENT_USER registry as a LocalSystem Service [C#]

07-27-2009, 07:11 PM
I have a little situation that I can't seem to resolve and was hoping someone might have some suggestions ...

I have a Windows Service (Serv.exe) which runs under LocalSystem when a user is logged-on (it is only running when users are logged-on), this service is responsible for performing various administrative tasks, one of which is applying registry (.reg) files when needed.

The Services uses REGEDIT (/s /i) to merge in the registry files (.reg) - and this is where things get rough - these registry files related to HKEY_CURRENT_USER (for the user currently logged on) - obviously this causes issues because regedit is being run as a LocalSystem (which is not currently in the HKCU of the user itself) ...

Is there anything I can do?
Can I somehow LINK to the users HKCU so that when I apply the .REG file it updates the users registry?
Can I mirror or reflex the changes somehow?

From where I stand my only solution would be to create my own REG EDIT that would redirect to the logged-on users HKCU (which would be a pain). I've already tried creating a service to mirror HKCU->HKLM but the LocalSystem doesn't seem to have an HKCU at all - so that doesn't help ...

Key point - I do NOT have the username & password of the User account so I cannot use Impersonation... And even there I need admin access to perform my changes.

Any help would be greatly appreciated...

07-27-2009, 11:09 PM
Well keep in mind that this problem is even more complex because there could be more than one user logged into the system at the same time.