I will try to be as brief as possible without attaching all the related source files. I have tracked down the issue as much as my Pascal knowledge allows me...
I thing I found a disk caching problem that occurs, for my case, at step ssInstall. I have an installer for an app that, if it finds an older app version installed, it will invoke an uninstallation like this:
procedure CurStepChanged(CurStep: TSetupStep);
var
uninstallStr: String;
ResultCode: Integer;
begin
if (CurStep = ssInstall) and IsUpdatableApplicationInstalled() then
begin
uninstallStr := GetUninstallString();
uninstallStr := RemoveQuotes(uninstallStr);
Result := Exec(uninstallStr, '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if Result and (ResultCode = 0) then
Log('CurStepChanged = ssInstall; uninstall OK');
//-------------
//Sleep(30000);
//-------------
end;
Also the folders/files are defined like this:
[Dirs]
Name: "{app}\db"; Flags: uninsalwaysuninstall
[Files]
Source: "..\bin\*"; DestDir: "{app}\bin"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\java\jre\*"; DestDir: "{app}\jre"; Flags: ignoreversion recursesubdirs createallsubdirs
blah...
Test case1; Normal installation: Everything goes smoothly. Log file part:
Starting the installation process.
Creating directory: C:\Program Files <---
Creating directory: C:\Program Files\MyApp <---
Creating directory: C:\Program Files\MyApp\db <---
Creating directory: C:\Program Files\MyApp\jre <---
Creating directory: C:\Program Files\MyApp\jre\lib
Creating directory: C:\Program Files\MyApp\jre\lib\applet
Directory for uninstall files: C:\Program Files\MyApp
Creating new uninstall log: C:\Program Files\MyApp\unins000.dat <--- !!!
-- File entry --
Dest filename: C:\Program Files\MyApp\unins000.exe <--- !!!
blah...
Test case2; Update old version: When getting to step ssInstall, the uninstaller launches, it finishes then the installation begins. Log file part:
CurStepChanged = ssInstall; uninstall OK
Starting the installation process.
Creating directory: C:\Program Files\MyApp\jre\lib
Creating directory: C:\Program Files\MyApp\jre\lib\applet
Directory for uninstall files: C:\Program Files\MyApp
Creating new uninstall log: C:\Program Files\MyApp\unins001.dat <--- !!!
-- File entry --
Dest filename: C:\Program Files\MyApp\unins001.exe <--- !!!
blah...
As you can see some folders do not get created and my app fails later on when it tries to write to 'db' folder.
If I uncomment the Sleep() command, everything runs smoothly and both the log files are identical.
It seems the disk has enough time to flush the changes! Somehow there must be a flush() command missing in inno-setup.
Can any of the inno-gurus comment or help somehow? Is there a flush() i could call, instead of the sleep()? Any help is appreciated. I just want to be sure before I file a bug request.
[Dirs]section ? If not, then when and how do you create them ? Could you include this information with a code related to the directory creation into your question, please ? - TLamaExecyou're calling withewWaitUntilTerminatedwait type ? - TLamaExec, then takes one last round of message processing. This is inHandleProcessWaitin 'InstFunc.pas' of Inno sources. It's at OS' dicretion, however, when to actually remove the deleted files etc.. I think there could be a function that would flush disk(s) cache. Until then you might try your own. Import and callFlushFileBufferspassing a handle for the volume(s) involved. Naturally this would require admin access. Can't guess if it would be trivial right now.. - Sertac Akyuz{app}then these files/folders cannot be deleted until the uninstaller actually exits. Inno's uninstaller manages this in such a way that it can delete these folders but it will still result in yourExeccall terminating slightly before the uninstaller has actually completed its job. As such waiting for it to "really" finish (which is basically what your Sleep call is doing) will be required before you proceed to start the installation. Which is another reason why uninstalling first is discouraged. - Miral