Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstallation order

Can I find somewhere actual order, in which events and sections are executed during uninstall? For example, will UninstallDelete occur earlier than usPostUninstall uninstall step?

Inno Setup has "Installation order" article in manual, but it looks more like compilation order, not execution.

like image 944
lentinant Avatar asked Jul 16 '15 14:07

lentinant


1 Answers

The uninstallation order is an opposite of the installation order, just as the manual says (and it is really the installation order, not a compilation order).

It's simply because there's no programmed uninstallation order. The installer records its steps into uninstall log and the uninstaller just processes the log in an opposite order, without any option to alter the order.

The event functions fit in the uninstallation process as follows (only major uninstallation steps shown):

  • CurUninstallStepChanged(usAppMutexCheck)
  • InitializeUninstallProgressForm
  • CurUninstallStepChanged(usUninstall)
  • Processing the uninstall log:
    • [UninstallRun]
    • registry entries
    • icons
    • files
    • application directory
    • [UninstallDelete]
  • 2nd attempt to delete directories (e.g. those that were not empty yet before)
  • CurUninstallStepChanged(usPostUninstall)
  • CurUninstallStepChanged(usDone)
  • DeinitializeUninstall

I've tested this on a simple installer:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=.

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

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

[UninstallRun]
FileName: "{app}\MyProg.exe"

[UninstallDelete]
Type: files; Name: "{app}\test.dat"
[Code]

function InitializeUninstall(): Boolean;
begin
  Log('InitializeUninstall');
  Result := True;
end;

procedure InitializeUninstallProgressForm;
begin
  Log('InitializeUninstallProgressForm');
end;

procedure DeinitializeUninstall;
begin
  Log('DeinitializeUninstall');
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  Log('CurUninstallStepChanged + ' + IntToStr(Integer(CurUninstallStep)));
end;

The uninstaller log is like (it does not show all the steps):

2015-07-19 10:47:54.845   Log opened. (Time zone: UTC+02:00)
2015-07-19 10:47:54.846   Setup version: Inno Setup version 5.5.5 (u)
2015-07-19 10:47:54.846   Original Uninstall EXE: C:\Program Files (x86)\My Program\unins000.exe
2015-07-19 10:47:54.846   Uninstall DAT: C:\Program Files (x86)\My Program\unins000.dat
2015-07-19 10:47:54.846   Uninstall command line: /SECONDPHASE="C:\Program Files (x86)\My Program\unins000.exe" /FIRSTPHASEWND=$1309D4 /INITPROCWND=$2509E4 /log=b:\uninstall\uninstall.log
2015-07-19 10:47:54.846   Windows version: 6.3.9600  (NT platform: Yes)
2015-07-19 10:47:54.846   64-bit Windows: Yes
2015-07-19 10:47:54.846   Processor architecture: x64
2015-07-19 10:47:54.846   User privileges: Administrative
2015-07-19 10:47:54.846   64-bit install mode: No
2015-07-19 10:47:54.846   Created temporary directory: C:\Users\martin\AppData\Local\Temp\is-4R498.tmp
2015-07-19 10:47:54.860   InitializeUninstall
2015-07-19 10:47:54.860   Message box (Yes/No):
                          Are you sure you want to completely remove My Program and all of its components?
2015-07-19 10:47:55.797   User chose Yes.
2015-07-19 10:47:55.797   CurUninstallStepChanged + 0
2015-07-19 10:47:55.802   InitializeUninstallProgressForm
2015-07-19 10:47:55.810   CurUninstallStepChanged + 1
2015-07-19 10:47:55.810   Starting the uninstallation process.
2015-07-19 10:47:55.810   Running Exec filename: C:\Program Files (x86)\My Program\MyProg.exe
2015-07-19 10:47:57.111   Process exit code: 0
2015-07-19 10:47:57.143   Deleting file: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My Program\My Program.lnk
2015-07-19 10:47:57.144   Deleting directory: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My Program
2015-07-19 10:47:57.144   Deleting file: C:\Program Files (x86)\My Program\MyProg.exe
2015-07-19 10:47:57.145   Deleting directory: C:\Program Files (x86)\My Program
2015-07-19 10:47:57.145   Failed to delete directory (145). Will retry later.
2015-07-19 10:47:57.145   Deleting file: C:\Program Files (x86)\My Program\test.dat
2015-07-19 10:47:57.145   Deleting Uninstall data files.
2015-07-19 10:47:57.662   Deleting directory: C:\Program Files (x86)\My Program
2015-07-19 10:47:57.665   Uninstallation process succeeded.
2015-07-19 10:47:57.665   Removed all? Yes
2015-07-19 10:47:57.665   Need to restart Windows? No
2015-07-19 10:47:57.668   CurUninstallStepChanged + 2
2015-07-19 10:47:57.668   Message box (OK):
                          My Program was successfully removed from your computer.
2015-07-19 10:47:58.342   User chose OK.
2015-07-19 10:47:58.342   CurUninstallStepChanged + 3
2015-07-19 10:47:58.342   DeinitializeUninstall
2015-07-19 10:47:58.343   Log closed.
like image 60
Martin Prikryl Avatar answered Sep 18 '22 23:09

Martin Prikryl