可以在创建 Windows 安装程序时授予应用程序文件夹的管理权限 [英] can give administration privileges to Application folder when creating windows installer

查看:42
本文介绍了可以在创建 Windows 安装程序时授予应用程序文件夹的管理权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理 WPF 项目.我想知道我可以在创建 Windows 安装程序时为应用程序文件夹授予管理员权限

I'm working with WPF project.I want to know can i give admin privileges to application folder when creating windows installer

推荐答案

长文:System.UnauthorizedAccessException 在程序文件下运行 .exe 时(除了下面列出的选项外,还有其他几个选项).

Longer Writeup: System.UnauthorizedAccessException while running .exe under program files (several other options in addition to the ones listed below).

您可以更改安装文件夹的 ACL 使其对普通用户可写,或者您可以使用清单来要求您的应用程序运行的管理员权限(普通用户用户通常无法提升任何这样的应用程序 - 除非他们输入管理员密码).然而,这样做是非常糟糕的设计 - 以至于您的应用程序可能会被拒绝在某些环境中使用.

You can change the ACL for the installation folder making it writable for regular users, or you can use a manifest to require admin rights for your application to run (regular users generally can't elevate any applications like this - unless they enter an admin password). However it is very bad design to do so - to the level where your application could be rejected for use in certain environments.

一种首选方法可能是确保将应用程序文件(数据和设置)存储在普通用户可直接写入的位置 - 无需在设置中进行任何修改或自定义.例如,您可以写入 My Documents%UserProfile% 中的某处.

A preferred approach could be to make sure you store the application files (data and settings) in locations writable for regular users outright - without any modifications or customizations in your setup. You could write to My Documents or somewhere in %UserProfile% - for example.

请参阅此现有答案以获得更详细的解释:C++ MSI 包管理权限.

Please see this existing answer for a slightly more fleshed-out explanation: C++ MSI Package Administative Privileges.

这篇关于可以在创建 Windows 安装程序时授予应用程序文件夹的管理权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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