安装到 Program Files 的应用程序是否有权修改其文件夹? [英] Do applications installed to Program Files have permissions to modify their folder?

查看:47
本文介绍了安装到 Program Files 的应用程序是否有权修改其文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将我的应用程序安装到程序文件中,它是否总是能够在其安装目录中创建和写入文件?它似乎适用于许多不同版本的 Windows,但是在某些情况下这不起作用吗?

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.

推荐答案

应用不是以用户身份运行,而是用户以用户身份运行.如果您将应用安装到 Program Files 中,并且假设您需要提升权限才能这样做,那么当您的标准用户运行该应用时,即需要权限的用户.

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. 应用以提升的权限安装(例如用户:Admin)
  2. AppName 文件夹的所有权限可能都是Admin:Full, Users:Read"
  3. 用户运行应用程序,因此无法更改任何文件

在安装时,您的安装程序需要知道哪些它自己的文件需要对标准用户可写,并相应地设置权限.当然,无论如何,用户数据应该在程序文件中.这通常是 %appdata% 和用户配置文件的用途.

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.

如果您的应用程序有一个 globalsettings.ini 或其他内容,位于Program Files\YourApp"中,那么当您拥有管理员权限时(即在安装时),您需要授予所有用户对该 globalsettings.ini 的写入权限文件.或高级用户.或者一组.或者任何适合您的应用的内容.

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.

总而言之,,用户没有对 ProgFiles 的默认写访问权限,也不应该.

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

这篇关于安装到 Program Files 的应用程序是否有权修改其文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆