Space Cracker

Dear All ,
I want to make a windows service to read data from Windows Registery
( using C# 2005)
i try to read data from registery but always return Empty value
althogh the same code i use in Windwos Application and work perfect
So please me in Reading values from Windows registery


Re: Visual C# General Help me in C# Windows Service ??

Galin Iliev

Take a look at this article How to read and write System Registry Keys using C# (VS.Net 2005)

It is strange that in windows service returns different value. This could be secirity issue. you can change credentials that windows service use to start as winforms app uses current user but the service use different account (Local system by default)

HTH






Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

thnx for ur help

but i try the same code but still return Empty Values in Windows Service and return Values in Windows Application

So can u explain me what Security Issues can make this code can't be run in Windows Service






Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

plz All can any one tell me if there are any Security Issues for making Windows Service (using C# 2005 )

reading and writting Data from Windows Registery






Re: Visual C# General Help me in C# Windows Service ??

Oliver Lundt - LN

Are you developing on Vista Vista has session 0 issolation. That means it not running in the same session as your user. I'm not sure how that would affect accessing CurrentUser Registery

Session 0 is a security measure in Vista. Other than that just check the ACL permissions in regedit that you can read and write to the registry.Hope that helps




Re: Visual C# General Help me in C# Windows Service ??

Sabrecat

Just a stupid thought here, but are you perhaps looking to read a key in Hkey_Current_User If so perhaps your service process is running as the wrong user



Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

No i develop on Windows XP not using Vista




Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

yes, i want to read a value from << HKEY_CURRENT_USER\Software\ ... >> so is there any probllem to Read this data

NOTE ::

i make the << Account >> property of << ServiceProcessInstaller >> to LocalSystem






Re: Visual C# General Help me in C# Windows Service ??

Ernst Kuschke

Which ever user your Windows Service is running as probably doesn't have permission to access the eventlog in this fashion. Try running the service as a user with access, or give the user it currently runs as, access to the eventlog.





Re: Visual C# General Help me in C# Windows Service ??

Sabrecat

Theres nothing inherently wrong with reading a key from HKey_current_user in a service. You just need to make sure that the user that the service is defined to run as has that particular key in its profile. By default a service will be configured to use the local system account. I would check to make sure that your service is configured to use the correct user, and further check to make sure that that user has the keys your looking for in its profile in the registry.

 

Edit: Just read where you said the service is using the Local System account.  I dont know how you would create a registry entry for the local system account, but Im betting thats your problem. Are you prevented from looking at the Hkey_local_machine key branch





Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

thnx all for ur help ,

Really I found the solution for my problem






Re: Visual C# General Help me in C# Windows Service ??

leqdangs

Hello Space Cracker
I meet problem like as you.
Can you share solution for me
Plz help me.
Thanks.




Re: Visual C# General Help me in C# Windows Service ??

Modi

HI leqdangs

if you find the solution then plz tell me also





Re: Visual C# General Help me in C# Windows Service ??

Space Cracker

Sorry fo late ,

the solution is that u can deal with HKEY_LOCAL_MACHINE or other but u can'nt deal with values in HKEY_CURRENT_USER