如何给读/写权限的文件夹使用.NET安装过程中, [英] How to give Read/Write permissions to a Folder during installation using .NET

查看:370
本文介绍了如何给读/写权限的文件夹使用.NET安装过程中,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装项目,我有建立使用Visual Studio 2010。

I have a Setup project that I have build using Visual Studio 2010.

安装程序工作正常,在安装应用程序的条款和其所有的依赖到他们的正确的子目录和程序数据目录。

The installer works fine in terms of installing the application and all its dependencies into their proper sub directories and Program Data directories.

不过,我注意到,每个目录(根文件夹及其所有子目录)创建不给安装程序写入权限。这将添加到用户组的目录中唯一的权限是:

However, I noticed that each directory (the root folder and all of its sub directories) that the installer created does not give "Write" permissions. The only permissions that are added to the directories for the "Users" group are:

  • 在读取和放大器;执行
  • 列出文件夹目录

这,显然默认的权限设置,将发生不管,如果用户安装该应用程序为管理员或没有。

This, apparent default permissions setting, will happen regardless if the user installs the application as "Administrator" or not.

这似乎很奇怪,我认为安装程序并没有给写入权限正在被使用,这是获得安装了应用程序的文件夹 - 这是更加令人困惑的是,安装在<$ C创建该文件夹$ C> ProgramData 文件夹的应用程序的数据库没有得到写入权限。

It seems odd to me that the installer doesn't give "Write" permissions to a folder that is being used by the application that is getting installed - It's even more confusing that the folder that the installer creates in the ProgramData folder for the application's database doesn't get "Write" permissions.

我的问题是,有没有办法来配置安装项目因此,如果当它创建一个文件夹,我们可以告诉它什么类型的权限给它,并为之。就我而言,我需要给根目录(应用)及其所有子目录,并放置在 ProgramData 文件夹中的文件夹的读取/写入权限用户群。从技术上讲,我是凉爽的用户组给迪尔斯完全控制。

My question is, is there a way to configure the Setup project so that if and when it creates a folder, we can tell it what type of permissions to give it and to whom. In my case, I need give the root directory (of the application) and all of its sub directories, and the folder that is placed in the ProgramData folder "Read/Write" permissions for the "Users Group". Technically, I'm cool with giving the dirs "Full Control" to the "Users Group".

推荐答案

在默认情况下,用户组不具有在每个机器的位置类似程序文件的写权限。这是一个标准的Windows这是不相关的安装。但是,在安装过程中你可以设置你想要的任何权限。

By default Users group doesn't have write access in per-machine locations like Program Files. This is a Windows standard which is not related to installations. However, during install you can set any permissions you want.

Windows安装程序不支持自定义权限,但Visual Studio不会设置他们提供了一种方法。因此,在Visual Studio中唯一的解决方案是一个自定义操作。

Windows Installer does support custom permissions, but Visual Studio doesn't offer a way for setting them. So the only solution in Visual Studio is a custom action.

不幸的Visual Studio不支持附加的自定义操作。因此,使用 Xcacls.exe在设置权限将只工作,如果你包括在你的包(它会在目标上安装机连同您的文件)。

Unfortunately Visual Studio doesn't support attached custom actions. So using XCACLS.EXE to set permissions would work only if you include it in your package (it will be installed on the target machine along with your files).

有一个更清洁,更复杂的解决方案是(使用定制code)来设置你想要的权限编写自定义的动作吧。

A cleaner, but more complex solution is to write a custom action yourself (using custom code) to set the permissions you want.

最快,最干净的解决方案是使用不同的设置创作工具,提供了更多的控制权限。

The fastest and cleanest solution would be to use a different setup authoring tool which offers more control over permissions.

这篇关于如何给读/写权限的文件夹使用.NET安装过程中,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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