NSIS:在 RequestExecutionLevel admin 之前获取当前用户

NSIS: get current user before RequestExecutionLevel admin

我的安装程序运行在所有用户中,它把用户信息保存在AppData文件夹中。

问题是,当安装完成后,一个可执行文件通过Exec启动,并以管理员用户身份启动,因此所有会话数据都存储在管理员的AppData中。我想 运行 以管理员身份安装,但最后一步以当前用户身份进行。

RequestExecutionLevel admin

我可以以当前用户身份启动我的应用程序吗?我可以在请求管理员权限之前保留当前用户吗?

Microsoft 准则说:

Certification requirements for Windows Desktop Apps

  • 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. When the app is installed, there is no correct user location in which to store data.

如果您有某种默认用户 data/template,您应该将其安装在 %ProgramFiles%%ProgramData% 中,并且您的应用程序应该在第一时间将该数据复制到 %AppData%用户运行您的应用程序。

ShellExecAsUser and StdUtils 插件可用于在完成页面上以 "real" 用户身份执行您的应用程序。

UAC plug-in允许你访问"real"用户%AppData%和注册表但是我不推荐这种方法,因为插件很难用而且它确实促进了不正确的行为。您很可能最终得到的安装模式仅适用于初始用户,而不适用于同一台机器上的其他用户。