Solved

My Application for All Users

Posted on 2014-10-01
7
124 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Emulate" TAB key when press Enter Key 3 46
MailAddress in vb 4 29
VB.NET String Settings and Temp Folder Question 3 53
Need syntax help building hyperlink 2 24
This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 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