views:

306

answers:

1

Hello All,

In Vista standard user can no more create or write to keys under HKLM\Software. So to port the code according to Vista standards in to which key i should write the application configuration data. Same way like %AllUsers%/AppData for folders. My main requirement is I should avoid writting to HKLM\Software, but the key location should be common to all users under registry.

Thanks, F

+2  A: 

The registry is a secure-able object. i.e. you can, during the administrative install, alter the ACL of a key you create, to create an all users read / write key in HKLM.

That said, Users\public\AppData might not work they way you think. The ACLs on that folder allow read by all users, but only creators can write. Which means you still can't have two users editing the same documents.

Chris Becke
I like Chris' answer but the security geek in me feels obliged to add a caveat: Once you mark the registry key as being writable for all users, you need to be careful to make sure that your app won't crash if the data is tampered with.
Larry Osterman
Suppose think a case where the user has not created the registry key during the installation. So when the application which has declared that it can run as "Standard User" checks if the key exists or not. If that does not exist it wants to create. So now being a standard user it cannot create any nodes under HKLM\Software.That why I was looking if there is any standard like knownfolder ids for folders, where we can write to registry keys that are accessible to all users. Hope you got my problem. Sorry for my bad english.
coolcake
In that case you are out of luck. The registry is not like the filesystem in that the rules there are much more strict. In its default configuration (ignoring apps that have tampered with ACLs) HKLM does not have any tiny piece that is configured to allow regular users to write to create entries.
Chris Becke
I agree that i cannot create the registry nodes under HKLM, so my question is; is there any registry node which is accessible to all the users?
coolcake
I can see you are desperate to avoid the truth. So, the answer is no. Not in HKLM. Not in HKCU. The other root keys are actually just links back into those two, or inappropriate for storing app data, and still don't have ACLs allowing users to write to multi user locations.If you must have config data shared between users thats writeable - put it on disk in CSIDL_COMMON_APPDATA because there is simply no way to get a shared writeable location in the registry without administrator elevation.
Chris Becke
Thank you very much Chris.
coolcake
Hello Chris,Yes you are true CSIDL_COMMON_APPDATA is also a problem for me. Back to the original problem, again i need to work on how to avoid folder virtualisation. Can you please help me in identifying a common folder location that is accessible for all the users and writable also.
coolcake
Again. There isn't one. However, when you create a folder, even as a user, as the creator you do get full access, including the right to set ACLs on the created object.The following link has code that will set full access for all users on a directory that it creates.http://stackoverflow.com/questions/690780/how-to-create-directory-with-all-rights-granted-to-everyone/696357#696357
Chris Becke
Thanks for the quick reply Chris. If I have create this folder on CommonAppData during installation and set the permissions during that time, is there a way for it? During the install i should be also able to get the folder id specific too that os, similar to known folder ids.
coolcake