【问题标题】:Can I create a Inno Updater that wont require admin privileges?我可以创建不需要管理员权限的 Inno 更新程序吗?
【发布时间】:2019-07-18 21:40:08
【问题描述】:

第一个 inno 安装程序,将应用程序安装为启动应用程序,这显然需要管理员权限。但是当我们更新我们已经存在的程序时,我不想要求管理员权限(这允许我们自动更新)

这是第一个需要管理员权限的安装程序脚本。

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "xxxx"
#define MyAppVersion "xxxx"
#define MyAppPublisher "xxxxxxx"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "xxxxxx.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{xxxxxxxxxxxxxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonappdata}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; The [Icons] "quicklaunchicon" entry uses {userappdata} but its [Tasks] entry has a proper IsAdminInstallMode Check.
UsedUserAreasWarning=no
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=admin
OutputBaseFilename=xxxxxx
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode

[Files]
Source: "C:\xxx\xxxx\Desktop\xxxxxx\xxxxx.exe"; DestDir: "{app}";
Source: "C:\xxx\xxxx\Desktop\xxxxx\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\{#MyAppExeName}"""; Flags: uninsdeletevalue

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent




更新脚本:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "xxxx"
#define MyAppVersion "xxxx"
#define MyAppPublisher "xxxxxxxxxx"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "xxxxxxx.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{xxxxxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonappdata}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; The [Icons] "quicklaunchicon" entry uses {userappdata} but its [Tasks] entry has a proper IsAdminInstallMode Check.
UsedUserAreasWarning=no
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=none
OutputBaseFilename=xxxxxx
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode

[Files]
Source: "C:\xxxx\xxxxx\Desktop\xxxxxxx\xxxxxxxx.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\xxxxx\xxxx\Desktop\xxxxxxxx\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent


现在我想编写一个不需要管理员权限的更新安装程序,只需更新文件。这是一个启动应用程序,这是它需要管理员权限的唯一原因。它必须是一个启动应用程序。

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    您仅为一位用户安装软件 (C:\Users\...):

    [Files]
    Source: "C:\Users\*****\Desktop\****\******.exe"; DestDir: "{app}"; Flags: ignoreversion
    

    但您将其设置为对所有用户启动 (HKLM):

    [Registry]
    Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\{#MyAppExeName}"""; Flags: uninsdeletevalue
    

    错了。 Windows 将尝试为登录到计算机的每个用户运行该软件。然而,只有一个用户可以访问该软件。所以其他人的启动会失败。

    如果您只想为一个用户安装软件,请将启动条目添加到 Run 键到 HKCU当前用户)仅配置单元,而不是 HKLM本地机器)。


    顺便说一句,有关您的字面问题的答案,请参阅
    Choose right Windows directory to install software and allow auto-updates
    但您的问题是 XY problem,所以我相信您实际上并不想要您所要求的。


    如果您实际上不介意任何用户可以修改/破解/感染应用程序,您可以创建两个安装程序。

    一,将进行初始安装:

    • 将文件写入文件夹,所有用户都拥有写入权限,例如{commonappdata}
    • HKLM 中创建[Run] 条目——满足PrivilegesRequired=admin 的需要。

    其他,只会更新程序:

    • 更新{commonappdata} 中的文件
    • 不修改注册表 - 因此可以使用 PrivilegesRequired=lowest

    两个安装程序应具有相同的AppId,以便他们可以共享安装数据。不过,我不确定它是否会在 Inno Setup 6 中很好地工作,它的 Side-by-side installation 功能。

    嗯,一般来说,你做的事情并不正确。

    【讨论】:

    • 如果我想为所有用户安装它...我会制作除用户以外的目录吗?谢谢!
    • 当然,那你应该把应用安装到C:\Program Files-{pf}
    • 我现在无法测试它,因为今天管理员走了。但是,如果我将程序文件更改为适用于所有用户的东西......然后取出 HKLM 并用 HKCU 替换它......我应该能够更新文件而无需写入任何具有特权的东西,它仍然是一个启动程序?我对 HKLM 和 HKCU 所做的唯一一件事就是我刚刚将 HKLM 换成了 HKCU……根据您告诉我的内容,我认为这已经足够了。
    • 我不确定我理解你想要什么。如果您希望在没有管理员权限的情况下更新应用程序,那么 1) 您需要链接问题中所示的服务。 2)或者应用程序需要安装到一个文件夹中,所有用户(或最终应该能够更新应用程序的用户)都具有写入权限。这也意味着所有这些用户都可以按照他们喜欢的方式修改/破解/感染应用程序。
    • 好吧,我有一个 C# 脚本,它下载最新版本(如果有的话),然后自动运行已编译的 inno setup .exe。如果他们真的不在乎破解程序,因为我们也在服务器端保护它。基本上,该程序需要默认安​​装为启动应用程序(需要管理员),如果它可以为所有用户或仅一个用户安装,那就太好了。但是我需要该程序能够自动下载最新的installer.exe然后更新文件,同时仍然保持自己作为启动程序,没有管理员
    猜你喜欢
    • 2010-09-09
    • 2018-06-25
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 2013-03-04
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多