无法将Inno Setup安装后运行项目发送给runasoriginaluser [英] Can't get Inno Setup postinstall Run item to runasoriginaluser

查看:203
本文介绍了无法将Inno Setup安装后运行项目发送给runasoriginaluser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 10中测试Inno设置.
我有PrivilegesRequired=lowest

I am testing an Inno Setup in Windows 10.
I have PrivilegesRequired=lowest

[Run]部分中的postinstall中,我启动一个Excel工作簿.
该工作簿为启动Excel的用户对Excel环境进行了更改.
默认情况下,该用户是标准用户,这就是我想要的.
但是,如果以右键单击的提升的特权运行,则该用户是管理员用户.
如何强制Excel为标准用户启动?

In the [Run] section with postinstall I launch an Excel workbook.
This workbook makes changes to the Excel environment for the user that launched Excel.
By default, that user is the standard user, which is what I want.
But if run with right-click elevated privilege, that user is the admin user.
How can I force Excel to launch for the standard user?

我尝试了标志runasoriginaluserrunascurrentuser,但是这两个标志都不会强制Excel为标准用户运行.

I tried the flags runasoriginaluser and runascurrentuser, but neither of these would force Excel to run for the standard user.

推荐答案

如果您以管理员身份明确运行安装程序,则无法访问用户会话. (请注意,这不是Inno Setup的限制,而是Windows的工作方式.)

If you explicitly run the installer as Administrator, there's no way to access the user session. (Note that it's not an Inno Setup limitation, it's how Windows works.)

您所能做的就是检测管理员权限,并通知用户不要以管理员身份运行安装程序.

All you can do is to detect the Administrator privileges and notify the user not run the installer as Administrator.

[Code]

function InitializeSetup(): Boolean;
begin
  Result := True;

  if (GetWindowsVersion >= $05010000) and
     IsAdminLoggedOn then
  begin
    MsgBox('Do not run this installer "As Administrator".', mbError, MB_OK);
    Result := False;
  end;
end;

有关详细信息,请参见从以管理员身份运行的Inno Setup安装程序中为当前登录的用户安装应用程序.

For details, see Installing application for currently logged in user from Inno Setup installer running as Administrator.

这篇关于无法将Inno Setup安装后运行项目发送给runasoriginaluser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆