我正在使用Inno Setup(http://www.jrsoftware.org/isinfo.php)为JavaFX应用程序创建本机包。
我想创建一个自定义步骤,在该步骤中询问用户是否要“按用户”或“按计算机”安装,以允许无特权的用户和管理员安装软件。
使用Inno Setup可以做到吗?如果可以,您能否提供跟踪信息?
看一下这个截图
Inno Setup 6内置了对非管理安装模式的支持。
基本上,您可以简单地设置PrivilegesRequiredOverridesAllowed
:
[Setup]
PrivilegesRequiredOverridesAllowed=commandline dialog
在以前的Inno Setup版本中没有如此简单的解决方案。
最简单的方法是将PrivilegesRequired
伪指令设置为none
(未记录的值):
[Setup]
PrivilegesRequired=none
这将允许安装程序由非特权用户运行。它只会为他/她安装。
对于特权用户,Windows通常会检测到该可执行文件是安装程序,并且会弹出UAC提示符。之后它将为所有用户安装。
有关详细信息,请仅在需要时才进行“使Inno Setup安装程序请求权限提升”
要使安装程序安装到“应用程序数据”中,当由非特权用户运行时,您可以执行以下操作:
[Setup]
DefaultDirName={code:GetDefaultDirName}
[Code]
function GetDefaultDirName(Param: string): string;
begin
if IsAdminLoggedOn then
begin
Result := ExpandConstant('{pf}\My Program');
end
else
begin
Result := ExpandConstant('{userappdata}\My Program');
end;
end;
如果您确实希望用户选择安装位置(尽管我认为没有必要让管理员自己安装),则可以执行以下操作DefaultDirName
:
[Code]
var
OptionPage: TInputOptionWizardPage;
procedure InitializeWizard();
begin
OptionPage :=
CreateInputOptionPage(
wpWelcome,
'Choose installation options', 'Who should this application be installed for?',
'Please select whether you wish to make this software available for all users ' +
'or just yourself.',
True, False);
OptionPage.Add('&Anyone who uses this computer');
OptionPage.Add('&Only for me');
if IsAdminLoggedOn then
begin
OptionPage.Values[0] := True;
end
else
begin
OptionPage.Values[1] := True;
OptionPage.CheckListBox.ItemEnabled[0] := False;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = OptionPage.ID then
begin
if OptionPage.Values[1] then
begin
{ override the default installation to program files ({pf}) }
WizardForm.DirEdit.Text := ExpandConstant('{userappdata}\My Program')
end
else
begin
WizardForm.DirEdit.Text := ExpandConstant('{pf}\My Program');
end;
end;
Result := True;
end;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句