Use a domain logon that can access remote registries for your service
rather than local system, which is the default. Services running under
local system have no network access.
[quoted text, click to view] Sheri Sourbeck wrote:
> I have a Windows service written in VB.net that needs read-only access to a
> remote registry. When the service attempts to access this registry I get
> "Access to the registry key is denied". The service is running on a Win2K
> system and the remote registry is on another Win2K system. The code works
> just fine from a Windows application, just not from a service.
>
> I have the following code in my service class:
> Imports System.Security.Permissions
>
> <Assembly: RegistryPermissionAttribute(
> SecurityAction.RequestMinimum, Read:="HKEY_LOCAL_MACHINE\SOFTWARE")>
>
> <Assembly: SecurityPermissionAttribute(
> SecurityAction.RequestMinimum, UnmanagedCode:=True)>
>
> My code that accesses the remote registry is in another class and looks like
> this:
>
> remotekey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,
> "\\" & m_sServerIPAddress)
>
> rkey = remotekey.OpenSubKey("SOFTWARE\ComputingDevices\OMT", False)
>
> sCurrentVersion = rkey.GetValue("CurrentVersion")
>
> Thanks in advance for your help.
>
That did the trick! Thanks!
[quoted text, click to view] "Lee Gillie" <Lee@nospam.odp.com> wrote in message
news:e2Zto6tuEHA.3456@TK2MSFTNGP14.phx.gbl...
> Use a domain logon that can access remote registries for your service
> rather than local system, which is the default. Services running under
> local system have no network access.
>
> Sheri Sourbeck wrote:
>> I have a Windows service written in VB.net that needs read-only access to
>> a remote registry. When the service attempts to access this registry I
>> get "Access to the registry key is denied". The service is running on a
>> Win2K system and the remote registry is on another Win2K system. The
>> code works just fine from a Windows application, just not from a service.
>>
>> I have the following code in my service class:
>> Imports System.Security.Permissions
>>
>> <Assembly: RegistryPermissionAttribute(
>> SecurityAction.RequestMinimum, Read:="HKEY_LOCAL_MACHINE\SOFTWARE")>
>>
>> <Assembly: SecurityPermissionAttribute(
>> SecurityAction.RequestMinimum, UnmanagedCode:=True)>
>>
>> My code that accesses the remote registry is in another class and looks
>> like this:
>>
>> remotekey =
>> RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "\\" &
>> m_sServerIPAddress)
>>
>> rkey = remotekey.OpenSubKey("SOFTWARE\ComputingDevices\OMT",
>> False)
>>
>> sCurrentVersion = rkey.GetValue("CurrentVersion")
>>
>> Thanks in advance for your help.
>>
Don't see what you're looking for? Try a search.