Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 4ac07e2

Browse files
authored
Windows uninstaller should stop cortex and remove cortex home folder for all users (#984)
Co-authored-by: Hien To <tominhhien97@gmail.com>
1 parent 4c53713 commit 4ac07e2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

cortex-js/installer.iss

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,50 @@ Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescri
3737
[Icons]
3838
Name: "{commondesktop}\Cortexso"; Filename: "{app}\cortex.exe"; Tasks: desktopicon
3939
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Cortexso"; Filename: "{app}\cortex.exe"; Tasks: quicklaunchicon
40+
41+
; Define the uninstall run section to execute commands before uninstallation
42+
[UninstallRun]
43+
Filename: "{app}\cortex.exe"; Parameters: "stop"; StatusMsg: "Stopping Cortexso service..."; Flags: runhidden
44+
45+
; Use Pascal scripting to delete the directory for all users
46+
[Code]
47+
function GetUsersFolder: String;
48+
var
49+
WinDir: String;
50+
begin
51+
WinDir := ExpandConstant('{win}');
52+
Result := Copy(WinDir, 1, Pos('\Windows', WinDir) - 1) + '\Users';
53+
end;
54+
55+
procedure DeleteUserCortexFolder;
56+
var
57+
UsersFolder: String;
58+
FindRec: TFindRec;
59+
begin
60+
UsersFolder := GetUsersFolder;
61+
if FindFirst(UsersFolder + '\*', FindRec) then
62+
begin
63+
try
64+
repeat
65+
if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
66+
(FindRec.Name <> '.') and (FindRec.Name <> '..') then
67+
begin
68+
if DirExists(UsersFolder + '\' + FindRec.Name + '\cortex') then
69+
begin
70+
DelTree(UsersFolder + '\' + FindRec.Name + '\cortex', True, True, True);
71+
end;
72+
end;
73+
until not FindNext(FindRec);
74+
finally
75+
FindClose(FindRec);
76+
end;
77+
end;
78+
end;
79+
80+
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
81+
begin
82+
if CurUninstallStep = usPostUninstall then
83+
begin
84+
DeleteUserCortexFolder;
85+
end;
86+
end;

0 commit comments

Comments
 (0)