如何创建一个“只适合我”的应用程序?为管理员用户安装?
当我以管理员用户身份运行安装脚本时,它将开始菜单条目放入“所有用户”配置文件中。如果他们是管理员用户并选择安装“Just for me”,我希望将开始菜单条目放置在当前用户的配置文件中。
我可以通过为 #define 选择两个值之一来完成此操作,但我不知道如何创建有条件包含的常量。我已经有一个 [Code] 部分例程,如果选择了“Just for me”安装,该例程将返回 true。这是这样的场景:
#define StartMenuLocation = "{somegroup}" ; check JustForMeInstall
#define StartMenuLocation = "{anothergroup}" ; check AllUsersInstall
...
[Icons]
Name: "{#StartMenuLocation}\{#MyAppName}" ; Filename: "{app}\{#ExeName}" ; parameters: "{#CommandArgs}" ; comment: "Starts {#MyAppName} {#MyAppVersion}"
...
[Code]
function JustMeInstall : boolean ;
begin
Result := (InstallationType = itJustMe) ;
end ;
function AllUsersInstall: boolean ;
begin
Result := (InstallationType = itAllUsers) ;
end ;
#defines 的“check”参数不受支持,当然会被忽略。
所以有两个问题:
我使用什么常量来定义开始菜单文件夹位置。 - InnoSetup 提供
{group}
,但此文件夹是在“所有用户”配置文件下创建的,除非安装应用程序的用户没有管理权限,在这种情况下,该文件夹是在用户的配置文件中创建的。我想要一个用于当前用户开始菜单文件夹的常量,该常量在该用户以管理员用户身份登录时起作用。如何实现如上所示的条件#defines(无论如何,在该问题之外具有普遍兴趣)。
When I run my install script as an admin user, it puts the start menu entries in the "All Users" profile. I want the start menu entries to be placed in the current user's profile if they are an admin user and choose to install "Just for me".
I can do it by selecting one of two values for a #define, but I can't figure out how to create a constant that is conditionally included. I already have a [Code] section routine that returns true if a "Just for me" install has been chosen. Here's the scenario:
#define StartMenuLocation = "{somegroup}" ; check JustForMeInstall
#define StartMenuLocation = "{anothergroup}" ; check AllUsersInstall
...
[Icons]
Name: "{#StartMenuLocation}\{#MyAppName}" ; Filename: "{app}\{#ExeName}" ; parameters: "{#CommandArgs}" ; comment: "Starts {#MyAppName} {#MyAppVersion}"
...
[Code]
function JustMeInstall : boolean ;
begin
Result := (InstallationType = itJustMe) ;
end ;
function AllUsersInstall: boolean ;
begin
Result := (InstallationType = itAllUsers) ;
end ;
where the "check" parameters for the #defines are not supported and of course ignored.
So two questions really:
what constants do I use to define the start menu folder location. - InnoSetup provides
{group}
, but this folder is created under the All Users profile unless the user installing the application does not have administrative privileges, in which case it is created in the user's profile. I want a constant for the current user start menu folder that works when that user is logged in as an admin user.how do you implement the conditional #defines as shown above (of general interest outside this problem anyway).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将 PrivilegesRequired 指令设置为最低,这意味着 Inno 只会为当前用户安装,无论它是否以管理员身份运行。
(这也意味着您无法将任何内容安装到系统位置。
请注意,这不能在运行时设置,因此如果您想允许这两种类型,则需要创建两个设置。
如果您只想更改图标,您可以有条件地使用
{userprograms}\{groupname}
或{commonprograms}\{groupname}
You set the PrivilegesRequired directive to lowest which means that Inno will install for the current user ONLY regardless of whether it's run as an admin or not.
(This also means that you can't install anything to the system locations.
Note that this can not be set at run time so you need to create two setups if you want to allow both types.
If you only want to change the location of the icons, you can conditionally use
{userprograms}\{groupname}
or{commonprograms}\{groupname}