My Application for All Users

Experts, I need my application to be available for all users on the PC. I have config files that are read and written to. I have registry entries that need to be read and written to. But for a standard user on the PC my application cannot write to ProgramData and cannot write to HKEY_Local_Machine. How do I do this? I have read everything I can find and have come up with no concrete answers. Everything looks like hacks. What is the correct way to do this?
BasicfarmerAsked:
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.

Jacques Bourgeois (James Burger)PresidentCommented:
If you use the standard .NET configuration files, that you can create through the Settings tab of the project's properties window, you can set each setting either as Application or User.

Application settings are read-only, but User settings are read and write. And the framework automatically handles settings for each users by writing these settings to the individual ApplicationData directory of each user.

You access each setting by My.Settings.NameOfTheSetting

You need to call My.Settings.Save when a change is made and you want to record it.

You cannot write to HKEY_Local_Machine, but you can write to HKEY_Current_User, which is were you would want to record individual information for each user anyway.
0
ElrondCTCommented:
I use ProgramData with my application (sold commercially) for config files, and there's no problem with Standard users reading and writing to them. The one caveat is that if you want multiple users to read & write the same file, it can't be created by an Administrator (or you have to go back and adjust the permissions on it), or Standard users won't be able to make changes.
0
BasicfarmerAuthor Commented:
ElrondCT, i have tried using ProgramData. Everything I have read says that is the place to be your files for an application that must be accessed by all users. I setup an account on my machine that is standard user account and i cannot write to the xml files that i have in my folder in ProgramData. I can read them just fine. What i have done is used my installer to set the permissions on my folder only to give the users group modify permissions. Is this the way it has to be done or is there some pitfall in doing it this way?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ElrondCTCommented:
I haven't needed to use the installer to set permissions. However, how are the xml files originally created? Is a Standard user creating them, or is an Administrator doing that, or is it happening as part of your installation?
0
BasicfarmerAuthor Commented:
It would be an administrator (me) creating them. How does who creates files or folders effect the user's ability to write to them when it is installed on their machine? How should I be creating things?
0
ElrondCTCommented:
The issue is that Windows is designed to protect Administrators from Standard users, but not the other way around, so if an Administrator user creates a file, he needs to explicitly authorize Standard users to make changes. You can do this by altering the permissions found on the Security tab of the Properties of the file. For Users, you should grant Full Control. (You can do this in VB as well using methods for Access Control Lists, but I don't have code for that.)

I avoid the problem by creating my ProgramData files when running the application for the first time. That way, it's the actual user who's creating the file (or copying it from the Program Files folder to ProgramData, in some cases), so they'll have full access afterwards. I still occasionally run into hassles when an Administrator (using someone in the IT department) installs the software in his account, then runs it from his own account to make sure it's working, and that creates the files which a Standard user then can't change...
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
BasicfarmerAuthor Commented:
Thank you, that was the most clear explanation i could have asked for. I am splitting the points for the comments James made on the HKLM registry hive.
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.