简体   繁体   English

NSIS安装程序:检测RequestExecutionLevel是否不起作用

[英]NSIS Installer: Detect if RequestExecutionLevel did not work

I have 我有

RequestExecutionLevel admin 

in my NSIS script. 在我的NSIS脚本中。

The problem is, if Windows UAC is set to "never notify" and a normal user runs the installer, the installer attempts to proceed anyways without asking for permissions and fails with an obscure message half way through when it attempts to modify a directory user doesnt have permission to. 问题是,如果Windows UAC设置为“从不通知”,并且普通用户运行安装程序,则安装程序尝试以任何方式继续进行而不征求权限,并且在尝试修改目录用户的过程中途中途出现一条晦涩的消息有权。

What I would like to do is fail fast and show a dialog right away saying "Please run as administrator". 我想做的是快速失败,并立即显示一个对话框,说“请以管理员身份运行”。

I have tried adding the following snippit I found, but it ALWAYS fails unless the user is actually an admin (but not normal user with Admin execution level). 我尝试添加发现的以下代码段,但是除非用户实际上是管理员(但不是具有管理员执行级别的普通用户),否则它始终会失败。

UserInfo::GetAccountType pop $0 ${If} $0 != "admin" MessageBox mb_iconstop "Administrator rights required!" SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED Quit ${EndIf}

There is no such thing as a normal user with administrator execution level. 没有具有管理员执行级别的普通用户。 When a non-admin wants to elevate they must use the credentials of a administrator and the new process runs as this administrator, not the user. 当非管理员要提升权限时,他们必须使用管理员的凭据,新流程将以该管理员(而不是用户)的身份运行。 This is called Over The Shoulder elevation... 这就是所谓的肩上高程...

Using UserInfo::GetAccountType is the correct solution. 使用UserInfo :: GetAccountType是正确的解决方案。

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

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