我可以创建不需要管理员权限的Inno Updater吗?

时间:2019-07-18 21:40:08

标签: inno-setup

第一个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


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

1 个答案:

答案 0 :(得分:0)

您只能为一个用户安装软件(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键中,而不是{{ 1}}(本地计算机)。


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


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

一个,它将进行初始安装:

  • 将文件写入所有用户都具有写访问权限的文件夹,例如{commonappdata}
  • 根据需要HKLM[Run]中创建HKLM条目。

其他,只会更新程序:

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

两个安装程序都应具有相同的AppId,以便它们可以共享安装数据。不过,我不确定它是否可以在具有Side-by-side installation功能的Inno Setup 6中正常运行。

嗯,总的来说,您所做的事情并不是很正确。