简体   繁体   English

admin level nsis安装程序需要为非特权用户创建图标

[英]admin level nsis installer needs to create icons for unprivileged user

I need to create an NSIS installer, which runs with administrator privileges. 我需要创建一个NSIS安装程序,它以管理员权限运行。 I request these privileges with 我要求这些特权

RequestExecutionLevel admin

So far this works. 到目前为止这个工作。 But I also need to place shortcut links on the users desktop. 但我还需要在用户桌面上放置快捷方式链接。 I do NOT want to create the shortcuts for all users but only for the currently logged in user. 我不想为所有用户创建快捷方式,只为当前登录的用户创建快捷方式。 So I use 所以我用

SetShellVarContext current 

in the installer sections. 在安装程序部分。 If the current user has admin privileges, this works. 如果当前用户具有管理员权限,则此方法有效。 If I have a normal user, Windows (7) asks for credentials for a privileged user, which is also correct. 如果我有普通用户,Windows(7)会要求特权用户的凭据,这也是正确的。 But the installer then creates the icons on the privileged users desktop, and not on current users. 但是,安装程序会在特权用户桌面上创建图标,而不是在当前用户上创建图标。

So, how can I tell NSIS, that it should create desktop icons for the current user if she has no admin privileges? 那么,我怎么能告诉NSIS,如果她没有管理员权限,它应该为当前用户创建桌面图标?

FYI, if I omit both RequestExecutionLevel and SetShellVarContext, I am also prompted for administrative rights but the installer creates icons on the current user desktop as well as for the admin user. 仅供参考,如果我省略了RequestExecutionLevel和SetShellVarContext,我也会被提示输入管理权限,但安装程序会在当前用户桌面和管理员用户上创建图标。 I think this is some kind of compatibility behavior. 我认为这是某种兼容行为。

You are not really supposed to do this (because of this exact issue) and you are basically asking how to create a installer that is broken by design. 你真的不应该这样做(因为这个确切的问题),你基本上是在询问如何创建一个被设计破坏的安装程序。 This is not a NSIS specific problem and not even UAC specific, it has existed since runas was added in Win2000! 这不是NSIS特定的问题,甚至不是UAC特有的,它已经存在,因为在Win2000中添加了runas! When you elevate with runas/UAC the new process is executed as that user and with their HKCU and shell folders... 当您使用runas / UAC进行提升时,新进程将作为该用户以及其HKCU和shell文件夹执行...

If you need "RequestExecutionLevel admin" in your script then you are doing machine level things and should therefore call "SetShellVarContext all" and install the files in $ProgramFiles and write the uninstall registration under HKLM. 如果您的脚本中需要“RequestExecutionLevel admin”,那么您正在进行机器级别的操作,因此应调用“SetShellVarContext all”并将文件安装在$ ProgramFiles中并在HKLM下编写卸载注册。 This is true for any version of NT, not just Vista+/UAC. 这适用于任何版本的NT,而不仅仅是Vista + / UAC。 (Most people forget to test as non-admin on NT4 and NT5) (大多数人忘记在NT4和NT5上测试为非管理员)

If creating shortcuts for all users is such a big problem then I suggest you enable the "Don't create shortcuts" checkbox on the startmenu page so the user can decide. 如果为所有用户创建快捷方式是一个大问题,那么我建议您在startmenu页面上启用“不要创建快捷方式”复选框,以便用户可以决定。

If you still want to force broken behavior then you need to use this plugin . 如果您仍想强制破坏行为,则需要使用此插件 (You should be able to find plenty of topics about this plugin on the NSIS forum ) (您应该能够在NSIS论坛上找到关于此插件的大量主题)

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

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