tags:

views:

49

answers:

1

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.

+3  A: 

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;
Andreas Rejbrand
Thanks for the super speedy reply! I found that [Code] function NotAnUpdate: Boolean; begin result := not FileExists(ExpandConstant('{app}\app.exe')); end;keeps the web page from opening--every time. Am I doing something wrong?
Al C
Sorry about that ... didn't know comments were unformatted :-(
Al C
@Al C: Hm... It shouldn't. Of course, you have to replace "app.exe" with the actual filename of your app, but that you know, right? However, "{app}" is a constant that will automatically be replaced by the path to your Program Files subfolder.
Andreas Rejbrand
@Al C: I forgot to add "result := " to the function. A very silly mistake. Sorry! Now it works!
Andreas Rejbrand
Yes, I knew those things. (I don't blame you for mentioning them, though :-) ... I find that the function always returns false. Could it be that the function always runs *after* TheFileNameOfMyApp.exe has been create?
Al C
@Al C: You are very right. You could try to test the existance of the file at the *initialization* of your setup, and save the value in a variable. I will update my answer.
Andreas Rejbrand
@Al C: The right time to check this is when you are just changing to the "Installing..." page, because then no files have been written yet, but you do have determined the value of the {app} constant (which is not determined at the initialization). So setting the variable `IsUpdate` at `CurPageChange` with `CurPageID = wpInstalling` seems to be the right thing to do.
Andreas Rejbrand
Gettin' closer! ... I think it should be "function InitializeSetup," rather than "procedure." ... The script compiled. I found, however, an error was generated because I was trying to expand the {app} constant before it was initialized.
Al C
Yes, I am way ahead of you! I edited my reply and added a comment minutes before you added this comment! :)
Andreas Rejbrand
Andreas -- Everything is working now. You da' man! I really appreciate your fast, patient, and helpful responses. I learned a lot. Thank you again.
Al C