Can Inno Setup respond differently to a new instal

2019-02-19 22:43发布

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.

2条回答
相关推荐>>
2楼-- · 2019-02-19 22:50

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;
查看更多
smile是对你的礼貌
3楼-- · 2019-02-19 23:10

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;
查看更多
登录 后发表回答