views:

304

answers:

2

Hi everybody,

I'm working hard on making my product work seamlessly on Windows 7. The problem is that there is a small set of global (not user-specific) application settings that all users should be able to change.

On previous versions I used HKLM\Software\__Company__\__Product__ for that purpose. This allowed Power Users and Administrators to modify the Registry Key and everything worked correctly. Now that Windows Vista and Windows 7 have this UAC feature, by default, even an Administrator cannot access the Key for writing without elevation.

A stupid solution would, of course, mean adding requireAdministrator option into the application manifest. But this is really unprofessional since the product itself is extremely far from administration-related tasks. So I need to stay with asInvoker.

Another solution could mean programmatic elevation during moments when write access to the Registry Key is required. Let alone the fact that I don't know how to implement that, it's pretty awkward also. It interferes with normal user experience so much that I would hardly consider it an option.

What I know should be relatively easy to accomplish is adding write access to the specified Registry Key during installation. I created a separate question for that. This also very similar to accessing a shared file for storing the settings.

My feeling is that there must be a way to accomplish what I need, in a way that is secure, straightforward and compatible with all OS'es. Any ideas?

A: 

Do you have to have it in the registry? If not, put it into a simple file, writable by everyone. Writing to HKLM requires additional privileges for a very good reason.

sibidiba
Do you know if C:\Users\Public is guaranteed to be writable by everyone? If it is, that may be a solution!
Kerido
Seems to me, but I'm really not a guru into that. As a corner case, I could also think of the user purging the files in that directory. Can't you store the global config file in the directory the program is installed into? Would be also more intuitive having a config directory/file there.
sibidiba
No it is not. Files created in Users\Public pickup rights that mean they are readable by all users, but writable by admins and creators. You need to adjust the ACLs of either the directory, or registry key 0 where you want an all-users read/write store.http://stackoverflow.com/questions/690780/how-to-create-directory-with-all-rights-granted-to-everyone/696357#696357
Chris Becke
A: 

I'm new to here (otherwise i would've left a comment) and i'm not a windows guru, but...

imho the premise is wrong:

there's a reason if a non-elevated user cannot modify registry keys or directories read by all users (like Users\Public by default)

i think that allowing any users to modify a small set of global application settings may be disruptive for the experience of the other users that didn't expect their settings to be modified

on the other hand i don't know your use cases...

could you please specify why all users should be able to modify these settings? and if indeed all users have to be able to do it... why can't you make these settings user-specific?