Nullsoft安装程序,Win7,如何安装读/写数据目录?
我们创建了一个安装程序(Nullsoft Install System v2.46)来安装应用程序,以及一些(嵌套)数据目录,其中包括从已安装的应用程序进行读/写访问的(文本)数据文件。
在 WinXP 上一切正常:应用程序加载,并且可以从安装目录下嵌套的数据目录读取/写入文件。
但是,在 Win7/64 上安装时,安装过程中创建的数据目录是只读的。因此,应用程序加载数据文件,但无法覆盖它们(因为它们驻留在安装目录下的只读数据目录中)。
是的,因为这是Win7-64位,所以数据目录恰好驻留在:
C:\Program Files (x86)\MyApp\MyDataDir0
我知道Win7的安装策略比以前的WinOS更严格(出于安全原因)。
问题:在安装过程中,我们应该使用什么机制来确保这些数据目录是读/写的,并且其中的(文本)数据文件也是读/写的?
这些数据文件不是用户的-特定的,它们意味着程序运行所需的数据。 (没有它们,程序就没用。)从逻辑上讲,它们是“程序系统”文件,尽管我们可以合理地认为它们代表程序使用的“可扩展数据集”(因此它们必须是读/写的)。
为了简单性和一致性,我们实际上宁愿使用安装程序来解决这个问题,而不是从程序内更改目录/文件权限。我们希望这些数据存在于安装应用程序的位置,而不是某些 C:/Users/Default/
中。或 C:/ProgramData/MyApp/.
目录。
我们对 data-dirs-under-app-install-dir 的“读/写”兴趣是否违反 Win7 政策? (我们不应该把它们安装在那里吗?)
We created an installer (Nullsoft Install System v2.46) that installs the application, plus some (nested) data directories, which include (text) data files that are read/write accessed from the installed application.
Everything works fine on WinXP: The application loads, and the files can be read/written from the data directories nested under the install directory.
However, installing on Win7/64, the data directories created as a part of the installation are read-only. Thus, the application loads the data files, but fails to overwrite them (since they reside in a read-only data directory under the install directory).
Yes, since this is Win7-64bit, the data directories happen to reside in:
C:\Program Files (x86)\MyApp\MyDataDir0
I understand that Win7 is more strict in its installation policy than previous WinOSes (for security reasons).
QUESTION: What mechanism should we use to ensure these data directories are read/write, and that the (text) data files within them are also read/write, during an install?
These data files are not user-specific, they imply data required for the program to run. (Without them, the program is useless.) Logically, they are "program system" files, although we could rationalize that they represent "extensible data sets" used by the program (so they must be read/write).
For simplicity and consistency we would really rather address this with the installer, and not change dir/file permissions from within the program. We would prefer that this data exists where the application is installed, and not in some C:/Users/Default/
. or C:/ProgramData/MyApp/.
directory.
Is our "read/write" interest in data-dirs-under-app-install-dir against the Win7 policy? (Are we supposed to not install them there?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你依赖于写入%ProgramFiles%,你的程序基本上在每个版本的WinNT上都会被破坏,你只是无法以非管理员身份进行测试!
如果您想允许每个人对文件或文件夹进行写访问,请使用访问控制插件。这样做你会放弃一点安全性。为了降低风险,请确保数据文件存储在子目录中(
%ProgramFiles%\MyApp\Data
或类似目录),并且不要授予普通用户对 . exe 或 .dll 的。您真正应该做的是在程序首次运行时将文件从%ProgramFiles%复制到%AppData%,这样每个用户都会获得自己的设置并且不存在安全问题。
If you rely on writing to %ProgramFiles%, your program is basically broken on every version of WinNT, you just failed to test as non-admin!
If you want to allow everyone write access to a file or folder, use the Access Control plugin. You give up a little bit of security by doing this. To reduce the risk, make sure the data files are stored in a sub directory, (
%ProgramFiles%\MyApp\Data
or something like that) and don't grant normal users write access to folders with .exe or .dll's.What you really should do is to copy the files from %ProgramFiles% to %AppData% when your program first runs, this way each user gets their own settings and there are no security issues.
实际上,您的应用程序无法在用户不是管理员的 Windows XP 下运行。 Windows 7/Vista 中 Program Files 目录的默认权限与 Windows XP 中相同。
根据您的描述,这些文件不是程序文件,而是程序数据文件,因此最好将它们存储在
ProgramData
目录中。要检索其位置,请调用SHGetFolderPath< /code>
函数,以
CSIDL_COMMON_APPDATA
作为参数。但是,即使在这种情况下,您也可能需要编辑应用程序文件夹权限以允许任何用户进行写入。如果您仍想将文件存储在 Program Files 中,那么您唯一的选择是在安装过程中编辑数据文件夹的权限。
Actually your application fails to work under Windows XP where user is not an administrator. The default permissions of Program Files directory in Windows 7/Vista are the same as in Windows XP.
From your description, those files are not Program Files but rather Program Data files, therefore it is better to store them in the
ProgramData
directory. To retrieve its location, callSHGetFolderPath
function withCSIDL_COMMON_APPDATA
as parameter. However, even in this case you may need to edit your app folder permissions to allow writing by any user.If you still want to store the files in Program Files, then your only option is to edit permission of data folders during installation.