Don’t Write User Files to ...
Posted: Sat Aug 21, 2004 4:21 pm
I am reading a book, and has some useful info so i put it here:
Don’t Write User Files to \Program Files
Writing to the \Program Files directory requires the user to be an administrator because the access control entry (ACE) for a user is Read, Execute, and List Folder Contents. Requiring administrator privileges defeats the principle of least privilege. If you must store data for the user, store it in the user’s profile: %USERPROFILE%\My Documents, where the user has full control. If you want to store data for all users on a computer, write the data to \Documents and Settings\ All Users\Application Data\dir.
Writing to \Program Files is one of the two main reasons why so many applications ported from Windows 95 to Windows NT and later require the user to be an administrator. The other reason is writing to the HKEY_LOCAL_MACHINE portion of the system registry, and that’s next.
------
Don’t Write User Data to HKLM
As with writing to \Program Files, writing to HKEY_LOCAL_MACHINE is also not recommended for user application information because the ACL on this registry hive allows users (actually, Everyone) read access. This is the second reason so many applications ported from Windows 95 to Windows NT and later require the user to be an administrator. If you must store data for the user in the registry, store it in HKEY_CURRENT_USER, where the user has full control.