如何在WIX中授予INSTALLDIR文件夹权限? [英] How to give INSTALLDIR folder permission in WIX?

查看:230
本文介绍了如何在WIX中授予INSTALLDIR文件夹权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个WIX 3.6安装程序项目,在安装过程中,我们需要向用户授予安装文件夹的文件创建权限(INSTALLDIR,尤其是默认安装文件夹程序文件",用户通常无法创建文件)在安装中.我们遇到了一些失败).我猜可以通过设置带有CreateFile属性的Permission元素来实现.但是,INSTALLDIR是目录,并且只有诸如CreateFolder,File,FileShare,Registry,ServiceInstall之类的元素才能具有Permission元素.谁能告诉我该怎么做?我的目录声明是这样的:

I am designing a WIX 3.6 installer project, during the installation we need to grand the user create file permission to the install folder(INSTALLDIR, especially with the default install folder, the Program Files, the user normally can't create file in the installation. We've experienced some failures). I guess it can be achieved by setting a Permission element, with CreateFile property. However, the INSTALLDIR is a directory, and only such elements as CreateFolder, File, FileShare, Registry, ServiceInstall can have permission element. So could anyone tell me how to do that? My directory declaration is something like this:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFiles64Folder">
      <Directory Id='MANUFACTUREFOLDER' Name='$(var.ManufacturerName)'>
        <Directory Id="INSTALLDIR" Name="$(var.ProductName)">

谢谢!

已更新: 现在,我设法创建了一个文件(不是已部署的文件.而是基于一个已部署文件生成的文件,并且它是在提交阶段的自定义操作中生成的).但是,现在我在删除刚才描述的已部署文件时遇到了问题(因为在成功生成另一个文件之后就不再使用它了).当安装文件夹为Program Files时,无法在自定义操作中将其删除.它说访问被拒绝.

UPDATED: Now I have managed to create a file (not the deployed file. But a generated file based on one deployed file, and it is generated in a custom action in commit phase). However, I now have a problem deleting the deployed file I just described (because there is no use of it after the other file is successfully generated). When the installation folder is Program Files, I can't delete it in the custom action. It says access denied.

另一件事是,我真的不了解CreateFolder元素的用途.如果其目的是创建一个文件夹,顾名思义,嵌套目录不会像我的示例代码那样做同样的事情吗?而且我认为在此描述文件夹结构更为清晰,因为将Component元素(CreateFolder元素将驻留在其中)和Directory元素分开是很常见的.该组件将只使用DirectoryReference来引用正确的目录.其次,将多个组件驻留在同一目录中也是很常见的.因此,如果我将CreateFolder添加到这些组件之一,并且将默认目录作为这些组件的公共父目录,那又意味着什么呢?这种结构真的不直观.

Another thing is, I really don't understand the purpose of CreateFolder element. If its aim is to create a folder, as its name implies, don't nested Directory(s) do the same thing, as in my example code? And I think it is more clear to describe the folder structure there since it is very common to separate the Component elements (in which CreateFolder elements will reside) and the Directory elements. The Component will just use DirectoryReference to refer to the correct directory. Secondly, it is also common that multiple Components reside in the same Directory. So if I add a CreateFolder to one of those Components, with the default directory as the common parent directory of those Components, what does it even mean? It is really not intuitive of such a structure.

推荐答案

如前所述,CreateFolder元素可能具有Permission元素,并且如果未指定目录,它们默认为父组件的目录.因此,该结构看起来类似于以下内容.

As you noted, CreateFolder elements may have Permission elements, and they default to the directory of the parent component if no directory is specified. So the structure would look something like the following.

<Directory Id="INSTALLDIR" Name="$(var.ProductName)">
  <Component>
    <CreateFolder>
      <Permission>
      </Permission>
    </CreateFolder>
  </Component>
</Directory>

但是,基于Vista和Windows 7的限制以及Windows徽标准则,如果您仍然对此有疑问,我不会感到惊讶,因为Program Files目录已被锁定.安装后,您不应写入该目录.

However, based on Vista and Windows 7 restrictions and Windows Logo guidelines, I wouldn't be surprised if you still have issues with this, since the Program Files directory is pretty locked down. After install you should not be writing to this directory.

这篇关于如何在WIX中授予INSTALLDIR文件夹权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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