Solved

My Application for All Users

Posted on 2014-10-01
7
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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