Solved

My Application for All Users

Posted on 2014-10-01
7
119 Views
Last Modified: 2014-10-02
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?
0
Comment
Question by:Basicfarmer
  • 3
  • 3
7 Comments
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 200 total points
ID: 40354964
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
 
LVL 20

Expert Comment

by:ElrondCT
ID: 40356247
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
 

Author Comment

by:Basicfarmer
ID: 40358090
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 20

Expert Comment

by:ElrondCT
ID: 40358575
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
 

Author Comment

by:Basicfarmer
ID: 40358579
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
 
LVL 20

Accepted Solution

by:
ElrondCT earned 300 total points
ID: 40358700
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
 

Author Closing Comment

by:Basicfarmer
ID: 40358703
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now