简体   繁体   English

NSIS:在RequestExecutionLevel管理员之前获取当前用户

[英]NSIS: get current user before RequestExecutionLevel admin

My installer run in all users, and it saves user information in the AppData folder. 我的安装程序在所有用户中运行,并将用户信息保存在AppData文件夹中。

The problem is that, when the installation is finished, an executable is launched by means of an Exec and it is launched as the administrator user, so all the session data is stored in the administrator's AppData. 问题是,当安装完成后,可执行程序通过Exec启动,并以管理员用户身份启动,因此所有会话数据都存储在管理员的AppData中。 I want to run the installation as Admin but the last step as the current user. 我想以管理员身份运行安装,但是作为当前用户运行最后一步。

RequestExecutionLevel admin

Can I launch my application as the current user? 我可以以当前用户身份启动我的应用程序吗? Can I keep the current user before ask for admin privilages? 在询问管理员权限之前,我可以保留当前用户吗?

The Microsoft guidelines say: 微软的指导方针说:

Certification requirements for Windows Desktop Apps Windows桌面应用程序的认证要求

  • Apps must install to the correct folders by default 默认情况下,应用必须安装到正确的文件夹
    • 10.6 Your app must write user data at first run and not during the installation in per-machine installations. 10.6您的应用必须在首次运行时写入用户数据,而不是在每台机器安装中安装期间。 When the app is installed, there is no correct user location in which to store data. 安装应用程序时,没有正确的用户位置来存储数据。

If you have some sort of default user data/template you should install that in %ProgramFiles% or %ProgramData% and your application should copy that data to %AppData% the first time a user runs your application. 如果您有某种默认用户数据/模板,则应将其安装在%ProgramFiles%%ProgramData%并且应用程序应在用户首次运行应用程序时将该数据复制到%AppData%

The ShellExecAsUser and StdUtils plug-ins can be used to execute your application as the "real" user on the finish page. ShellExecAsUserStdUtils插件可用于在完成页面上以“真实”用户身份执行您的应用程序。

The UAC plug-in allows you to access the "real" users %AppData% and registry but I don't recommend this approach because the plug-in is hard to use and it really promotes incorrect behavior. UAC插件允许您访问“真正的”用户%AppData%和注册表,但我不建议这种方法,因为插件很难使用,它确实促进了不正确的行为。 You are very likely to end up with a install pattern that only works for the initial user and not other users on the same machine. 您很可能最终得到的安装模式仅适用于初始用户,而不适用于同一台计算机上的其他用户。

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

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