Can Inno Setup respond differently to a new install and an update?

后端 未结 2 1580
心在旅途
心在旅途 2020-12-06 15:28

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: shellex         


        
2条回答
  •  心在旅途
    2020-12-06 15:51

    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 is your "AppId" contains a left-curly-bracket:
    Checking if installation is fresh or upgrade does not work when AppId contains a curly bracket

提交回复
热议问题