Inno Setup 对新安装和更新的响应是否不同?

发布于 2024-09-08 15:58:50 字数 272 浏览 5 评论 0原文

我的 InnoSetup 脚本在安装过程结束时打开一个网页(使用用户的默认浏览器):

[Run]
Filename: http://example.com; Flags: shellexec

但是,如果应用程序已存在,我希望不打开该网页,即,如果用户正在安装该程序的新版本。该网页应该在初始安装后打开。 (我认为值得一提的是,安装显然包括一个 AppID,并在安装文件旁边的注册表中输入值。)

一如既往地谢谢您 - Al C.

My InnoSetup script opens a web page (with the user's default browser) at the end of the install process:

[Run]
Filename: http://example.com; Flags: shellexec

However, I'd like the web page to not be opened if the app already exists, i.e., if the user is installing a new version of the program. The web page should only be opened after the initial install. (I assume it's worth mentioning that the install includes an AppID, obviously, and enters values in the registry beside installing files.)

Thank you, as always -- Al C.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你的占有欲 2024-09-15 15:58:50

是的,这很容易通过脚本来完成。

只要写

[Run]
Filename: "http://example.com"; Flags: shellexec; Check: NotAnUpdate

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpInstalling then
    IsUpdate := FileExists(ExpandConstant('{app}\TheFileNameOfMyApp.exe'));
end;

function NotAnUpdate: Boolean;
begin
  result := not IsUpdate;
end;

Yes, this is easy to do with scripting.

Just write

[Run]
Filename: "http://example.com"; Flags: shellexec; Check: NotAnUpdate

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpInstalling then
    IsUpdate := FileExists(ExpandConstant('{app}\TheFileNameOfMyApp.exe'));
end;

function NotAnUpdate: Boolean;
begin
  result := not IsUpdate;
end;
却一份温柔 2024-09-15 15:58:50

如果用户选择将可执行文件安装到其他位置,@AndreasRejbrand 的答案将不起作用

您可以查询特定于安装程序的 Inno Setup 注册表项:

#define AppId "your-app-id"
#define SetupReg \
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\" + AppId + "_is1"
#define SetupAppPathReg "Inno Setup: App Path"

[Setup]
AppId={#AppId}
...

[Run]
Filename: "https://www.example.com/"; Flags: shellexec; Check: not IsUpgrade
...
[Code]

function IsUpgrade: Boolean;
var
  S: string;
begin
  Result :=
    RegQueryStringValue(HKLM, '{#SetupReg}', '{#SetupAppPathReg}', S) or
    RegQueryStringValue(HKCU, '{#SetupReg}', '{#SetupAppPathReg}', S);
end;

有关如何在 [Code] 部分中使用 IsUpgrade 的示例,请参阅
如果在 Inno Setup 中更新安装,则排除 ssPostInstall 步骤中的部分代码部分

如果您的“AppId”包含 left-,请选中此项大括号:
当 AppId 包含大括号时,检查安装是否是全新安装或升级不起作用

The answer by @AndreasRejbrand won't work, if user chooses to install the executable to a different location than the last time.

You can query installer-specific Inno Setup registry keys:

#define AppId "your-app-id"
#define SetupReg \
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\" + AppId + "_is1"
#define SetupAppPathReg "Inno Setup: App Path"

[Setup]
AppId={#AppId}
...

[Run]
Filename: "https://www.example.com/"; Flags: shellexec; Check: not IsUpgrade
...
[Code]

function IsUpgrade: Boolean;
var
  S: string;
begin
  Result :=
    RegQueryStringValue(HKLM, '{#SetupReg}', '{#SetupAppPathReg}', S) or
    RegQueryStringValue(HKCU, '{#SetupReg}', '{#SetupAppPathReg}', S);
end;

For an example how to use IsUpgrade in [Code] section, see
Excludes part of Code section in ssPostInstall step if installation is update in Inno Setup

Check this if your "AppId" contains a left-curly-bracket:
Checking if installation is fresh or upgrade does not work when AppId contains a curly bracket

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文