Operating system: Windows 2003 server

Hello Gurus,

The Following is the issue that iam facing while accessing Windows Registry:

Description:
we use a service which sets values to a few keys in HKLM\SYSTEM\CurrentControlSet\Services\Test\Parameters\Control
during the start of application. When we reboot the system, the service deletes the values associated with those keys before it gets stopped. So that, when the server comes up after reboot, it will not read the old values.

The problem is, during the start of the application, all keys are getting created properly, but, during reboot, when the service
is trying to access the registry to reset the values, all the Registry API calls( RegOpenKey, RegCreateKeyEx etc..) are failing with windows error 19( ERROR_WRITE_PROTECT).

NOTE: The service has full Domain and Local administrator rights and full control over the registry.

Even a GetComputerName() API is returning 0 with GetLastError 19(ERROR_WRITE_PROTECT).

From the event logs, we observed that there are a few entries logged having Event ID: 1517 which means:

"Windows saved user MGMT-XHA\svcbhaslm registry while an application or service was still using the registry during log off.
The memory used by the user's registry has not been freed. The registry will be unloaded when it is no longer in use."
This is often caused by services running as a user account, try configuring the services to run in either the LocalService or NetworkService account."

Later we installed UPHClean on the server and did a reboot and found the server frozen while rebooting. We did a hard reset to restart the server.

UPHClean logged the following entry into the event viewer:

The following handles in user profile hive MGMT-XHA\svcbhaslm (S-1-5-21-3690111373-1527127378-4234617882-1903) have been closed because
they were preventing the profile from unloading successfully:
lsass.exe (860)

HKCU\Software\Microsoft\SystemCertificates\Root (0x914)

call stack data collection not enabled for this process
HKCU\Software\Microsoft\SystemCertificates\CA (0x920)

call stack data collection not enabled for this process
HKCU (0x924)

call stack data collection not enabled for this process
HKCU\Software\Microsoft\SystemCertificates\Disallowed (0x930)

call stack data collection not enabled for this process
HKCU (0x934)

call stack data collection not enabled for this process
HKCU\Software\Policies\Microsoft\SystemCertificates (0x958)

call stack data collection not enabled for this process
HKCU\Software\Microsoft\SystemCertificates\trust (0x980)

call stack data collection not enabled for this process
HKCU (0x984)

call stack data collection not enabled for this process
HKCU\Software\Microsoft\SystemCertificates\My (0x990)

call stack data collection not enabled for this process
HKCU\Software\Policies\Microsoft\SystemCertificates (0x9cc)

call stack data collection not enabled for this process
HKCU\Software\Policies\Microsoft\SystemCertificates (0x9f8)

call stack data collection not enabled for this process.

Can any one help us in identifying the reason / solution for failure of these registry API's?

Thanks in advance,
Harish Reddy