Do applications installed to Program Files have permissions to modify their folder?

断了今生、忘了曾经 提交于 2019-11-28 05:19:53

问题


If I install my app to program files, will it always be able to create and write files within its install directory? It seems to work in a lot of different versions of windows, but are there situations where this wouldn't work?

Mainly I'm using this approach for logging. If this is not the correct approach, is there a better place to log?

Note: My installer requires Admin privileges to run and it grants Full Access to all users in the install directory.


回答1:


Apps don't run as users, users run as users. If you install an app into Program Files, and let's assume you needed elevated permissions to do so, when your standard user then runs that app, that is the user that needs permissions.

  1. App is installed with elevated permissions (user: Admin, for example)
  2. All permissions on the AppName folder might well be "Admin:Full, Users:Read"
  3. User runs app, so cannot change any files

At install-time, your installer will need to know which of it's own files need to be made writable to standard users, and set permissions accordingly. Of course, user-data should not be in Program Files anyway. That's what %appdata% and the user profile are for, usually.

If your app has a globalsettings.ini or whatever, that lives in "Program Files\YourApp", then while you have admin permissions (i.e. at install time) you need to grant write permission to all users to that globalsettings.ini file. Or Power Users. Or a group. Or whatever is correct for your app.

In summary, no, users do not have default write-access to ProgFiles, nor should they.




回答2:


Yes, there are definitely situations where this won't work, such as when your app is running on Windows 7, or if your user account is a limited user.

We always put our log files in a temp directory or a special folder such as AppData.



来源:https://stackoverflow.com/questions/8424412/do-applications-installed-to-program-files-have-permissions-to-modify-their-fold

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!