Access registry HKEY_CURRENT_USER subkey from NT Service
Posted on 2002-06-20
System : Win NT Server 4.0 or Windows 2000 Adanced Server.
Server is logged in with NT account (say AAA) and
some values are stored in Registry under HKEY_CURRENT_USER branch.
An application reads from the above subkey and works fine.
The application is converted to NT service (service startup is automatic) and made to run with same NT account AAA.
Now, when the server is logged on with NT account AAA and if the service is started, it reads values from registry and works fine.
However, when the server is restarted and NOT logged-on with any nt user account, and when the service starts automatically, it is NOT able to read the registry values.
I understand that registry values under HKEY_CURRENT_USER created with one NT account (say AAA)is available only if server is logged on with same NT account (AAA).
Also, if some other NT account (say BBB) log-on to the server,the HKEY_CURRENT_USER branch created by NT account AAA is not available to applications.
But, I've provided same NT account (AAA) for service to log-on, still if the server restart, the service could not read from HKEY_CURRENT_USER branch.
In UserManager, I added "act as part of operating system" and "log on as batch job" and "log on as service" previleges to the NT account AAA.
Still, registry reading fails on re-start.
Q1. Is there a way to access HKEY_CURRENT_USER branch when the server is not logged on with NT account AAA.
Q2. Can I move the registry content to HKEY_LOCAL_MACHINE branch and restrict the access only to the NT account AAA ?.
Experts, please help.