简体   繁体   English

如何授予使用NSIS安装目录的权限?

[英]How to grant the permissions on Install Directory with NSIS?

I am new to NSIS commands. 我是NSIS命令的新手。 I have a installer file and I am granting the GenericRead and GenericWrite permissons on my InstallDir. 我有一个安装程序文件,并在InstallDir上授予了GenericReadGenericWrite权限。

Below is the code: 下面是代码:

AccessControl::GrantOnFile "$INSTDIR\\WPFUI" "(BU)" "GenericRead + GenericWrite" AccessControl :: GrantOnFile“ $ INSTDIR \\ WPFUI”“(BU)”“ GenericRead + GenericWrite”

Now problem is: any non admin user can copy new files and dlls in my install directory. 现在的问题是:任何非管理员用户都可以在我的安装目录中复制新文件和dll。

I want to set the required permission which requires admin rights to copy any new files. 我想设置所需的权限,该权限需要管理员权限才能复制任何新文件。

I've tried my luck with GenericRead + GenericExecute but still does not work. 我已经尝试了GenericRead + GenericExecute运气,但仍然无法正常工作。

Could someone please throw any light on this? 有人可以对此进行说明吗?

You should not let normal users any kind of write access to $InstDir if you are installing to a common location like $ProgramFiles because you end up with issues if multiple users on the same machine are using your program. 如果要安装到$ ProgramFiles这样的公用位置,则不应让普通用户对$ InstDir具有任何类型的写访问权限,因为如果同一台计算机上的多个用户正在使用您的程序,最终会遇到问题。 There are also security issues to think about. 还有一些安全问题要考虑。

The correct solution is to change your application so that it copies "template data" from $InstDir to $AppData and/or $LocalAppData the first time a user runs your application. 正确的解决方案是更改应用程序,以便在用户首次运行应用程序时将“模板数据”从$ InstDir复制到$ AppData和/或$ LocalAppData。

If you don't want to do it this way then you need to be more restrictive in how you change the ACL. 如果您不想这样做,则需要对更改ACL的方式进行更多限制。 You could for example try to restrict it with 例如,您可以尝试用

AccessControl::GrantOnFile /NOINHERIT "$INSTDIR\WPFUI" "(BU)" "GenericRead + GenericWrite"
AccessControl::DenyOnFile /NOINHERIT "$INSTDIR\WPFUI" "(BU)" "AddFile"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM