Click here to Skip to main content
15,888,908 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
When files are locked during the silent Inno Setup(actually the update), user gets MsgBox allowing him to ignore file replacement. After setup is finished, the process exists with ExitCode=0 meaning setup is completed. Since not all files are replaced, you can not be 100% sure that setup is fully completed.

UPDATE:
Thank you Valery, unfortunately your answer can not solve my problem since MakePendingFileRenameOperationsChecksum returns the same checksum before and after the update part! This happens if PrivilegesRequired is set to lowest and not admin?

After waisting some time with trial-and-error coding, I've discovered that when /SUPPRESSMSGBOXES switch is used, the returned ExitCode is 5(setup is aborted)! This is good enough for me!

What I have tried:

* seaching for some function or variable in the Inno Setup API to check if 100% completed;
* validating ExitCodes;
* googling;
* comparing checksums of all files before and after setup(too much work);
* coding replacement in setup itself to have more control(too much work);
Posted
Updated 6-Feb-17 9:56am
v9

1 solution

Hello,

In the past I did this using
MakePendingFileRenameOperationsChecksum
and returning a custom error code.

If a file is in use and the user selects ignore, then Inno setup will set a reboot pending flag.

Example script:

Source: "MyProg.exe"; DestDir: "{app}";
Source: "MyProg.chm"; DestDir: "{app}"; Flags: restartreplace;
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]
var
  Restarted: Boolean;
  ChecksumBefore: String;
  ChecksumAfter: String;

procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall';

procedure ReturnRebootNecessary();
begin
    ExitProcess(9); //Custom exit code
end;

function InitializeSetup(): Boolean;
begin
    ChecksumBefore := MakePendingFileRenameOperationsChecksum;
    Result := True;
end;

procedure DeinitializeSetup();
begin
    ChecksumAfter := MakePendingFileRenameOperationsChecksum;
    if ChecksumBefore <> ChecksumAfter then
    begin
         ReturnRebootNecessary();
    end;
end;


Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900