2
votes

We package few other thirdparty softwares along with our installer,and also install them during the installation of our product. We install them in silent mode and capture their exit codes, so sotimes, they get installed successfully and give exitcode as "3010" which is reboot required. So, in those cases we want to show reboot page at the last but want to give a custom message.

what is the best way to show the custom message on the finish page?

[Messages]
#if FileExists("c:\RebootFile.txt")==0 
  FinishedRestartLabel=To complete the installation of ConditionalMessageOnWizard, Setup must restart your computer. Would you like to restart now?
#else
  FinishedRestartLabel=Reboot Required
#endif

I am using the above code, but i am unable to use the dynamic paths like {sd} or {tmp} for fileexists function.

Can anyone help?

1
The {tmp} constant value will be useless at preprocessing time...TLama
Wait, and are you even sure you want to do this by preprocessing ? Don't you rather want to conditionally change that message at runtime ? Your script will choose the FinishedRestartLabel text depending on if that file exists at build time of your setup, not at runtime on client's machine. Could you edit your question and elaboate on your requirement, please ?TLama
If reboot required, we are changing FinishedLabel message on runtime during wpfinishedpage. It's working fine.user1752602
Well, but only one of the message texts will be compiled into the setup (which you then distribute). It looks for me really weird that you're checking if a certain file exists (on a machine where the setup is compiled) with the preprocessor and depending on the result of its existence you compile a message text into the setup. I feel that you want to check if that file exists on the machine, where the user run the setup, don't you ?TLama
We are checking if that file exists, where the user runs setup, then we are changing finishedlabel message.user1752602

1 Answers

2
votes

After clarification of your problem, we've found that you actually want to check if a certain file exixts and conditionally change the FinishedLabel caption at runtime.

The #emit, or in short # starting statements are used by preprocessor. And preprocessing runs right before the compilation. It allows you to conditionally modify the script, which is, after this process is done, compiled. So, with your above script you are in fact checking, if the file c:\RebootFile.txt exists on the machine where the setup is being compiled and depending on the result it then chooses value of the FinishedRestartLabel message. But it never compiles both texts into the setup binary.

You can modify the FinishedLabel caption from code e.g. this way. There you can expand constants without any problem:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
function NeedRestart: Boolean;
begin
  Result := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if not FileExists(ExpandConstant('{sd}\RebootFile.txt')) then
    WizardForm.FinishedLabel.Caption := 'RebootFile NOT found. Restart ?'
  else
    WizardForm.FinishedLabel.Caption := 'RebootFile WAS found. Restart ?';
end;