?
Solved

My Application for All Users

Posted on 2014-10-01
7
Medium Priority
?
137 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 800 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

764 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