Reputation: 1865
I have written a window service. and I am able to successfully install/run the service. Now I have added a timer to the service and I want to be able to adjust the interval via the registry. But I can't figure out why GetSetting("MyAppName", "MySection", "IntervalSetting")
will NOT return the value in the registry!
Am I missing something? Does GetSetting() not work when called from a windows service?
Upvotes: 0
Views: 633
Reputation: 6894
From MSDN :
"GetSetting requires that a user be logged on since it operates under the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively."
What account does your service operate under? If it's LocalSystem, you effectively have no user logged on. Even if you impersonate, IIRC, that doesn't load the registry hive.
Upvotes: 2
Reputation: 3718
does the user the service is running under have access to the registry?
Upvotes: 0