Persist settings in file for windows service + windows app

Hello Experts,

I'm developing in VB.net 4.0 Framework...

I have a windows service that needs to pull some configuration settings from a file.  I am creating a sister windows application that will allow the user to edit the configuration settings for the windows service and persist them to this configuration file.  I can't/don't want to use a database, as one of the primary purposes of the service is to notify admins via email if there is a problem connecting to the database it uses, so it needs to just be a simple configuration file.  I am aware that UAC protects certain locations and prevents normal access to those locations (like anything in the Program Files folder).  So the previously obvious place that I would store this configuration file won't work.

What is the standard practice for doing this type of thing?  Is there a special location that windows has set aside for things of this nature?  Will I have issues because there will be an installed windows application that needs to read/write to this configuration file, and also have a service that needs to be able to locate this file and read from it?  Open to ideas or links to places that explain how I should handle this.

Thank you for your time!
LVL 1
JahelkaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

parnassoCommented:
Certainly the UAC protects locations and also prevents less priviledges processes to access to resources like configuration files, registry keys and so on.

In your case, in addition to the UAC, you have to manage the fact that your windows service run as local service account, and your configuration program might be running as different user accounts, so you can not write the configuration file in the %APPDATA% directory (where a user can write&read and the UAC says nothing)

I strongly believe that the best approach would be that the windows service were the only one who actually read/writes into the configuration file and exposes an interface to update the configuration thorugh interprocess communication IPC. Then the configuration program can use your interface to read/update the configuration file without knowing where is it, and avoiding the UAC issues since the windows service can change the configuration file without UAC problems.

IPC in .NET could be remoting, pipes, sockets, RPCs, web services or whatever you find yourself most confortable with.

Hope this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CodeCruiserCommented:
I think you can use the C:\ProgramData folder.
0
JahelkaAuthor Commented:
Hi Parnasso,

I think what you are recommending might be the way to go.  I was thinking I would have to have the the windows app write the configuration file, and the service just read it.  I got this from some reading in my reference books, and they all say that you can't pass a string or anything else to a service through the service control manager, only a set of 128 numeric commands.  I want the windows app front end to allow the user to modify an email notification list, and it appears that I have to use something besides the service control manager to get that data there.

I have never had the need for anything IPC, so I haven't used it at all.  And frankly, I didn't intend for this to be incredibly complicated.  This is a custom app that will be installed on one single server.  I prefer anytime I can to follow "best practices" so that I don't have to rewrite stuff later on.  But perhaps as simple as my case is, I should just make a special folder as part of the install, and write both the app and the service so that they assume the configuration file is in the same place, and leave it at that.  Otherwise I can see myself spending a couple of day's time writing and debugging something that could be solved easily if I just impose some limitations on myself and the application.

If you guys have anything else to add, then please do so.  I'll let this sit for another day or two and see if someone else doesn't have a bright idea for the best way to do this before throwing points out.

Thanks guys!
0
Tom KnowltonWeb developerCommented:
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
CodeCruiserCommented:
Accept: http:#35331020
Assist: http:#35331065
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.