Repository navigation
Expand file tree
/
Copy pathsetup.iss
More file actions
553 lines (497 loc) · 22.8 KB
/
Copy pathsetup.iss
File metadata and controls
553 lines (497 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#ifndef AppVersion
#define AppVersion "1.0.0-rc.1"
#endif
#ifndef AppVersionInfoVersion
#define AppVersionInfoVersion "1.0.0.0"
#endif
[Setup]
AppName=LocalTelemetry
AppVerName=LocalTelemetry
AppVersion={#AppVersion}
AppPublisher=Nicconike
AppPublisherURL=https://github.com/Nicconike/LocalTelemetry
AppSupportURL=https://github.com/Nicconike/LocalTelemetry/issues
AppUpdatesURL=https://github.com/Nicconike/LocalTelemetry/releases
VersionInfoVersion={#AppVersionInfoVersion}
VersionInfoProductVersion={#AppVersionInfoVersion}
VersionInfoDescription=LocalTelemetry Setup
VersionInfoCopyright=Copyright (C) 2026 Nicconike
VersionInfoOriginalFileName=LocalTelemetrySetup.exe
DefaultDirName={commonpf}\LocalTelemetry
DefaultGroupName=LocalTelemetry
OutputDir=.
OutputBaseFilename=LocalTelemetrySetup
Compression=lzma2
AppId={{LocalTelemetry_TaskbarApp}}
SetupIconFile=src\LocalTelemetry.App\app.ico
UninstallDisplayIcon={app}\LocalTelemetry.exe
WizardStyle=modern
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64compatible
ArchitecturesAllowed=x64compatible
MinVersion=10.0.19041
DisableDirPage=auto
DisableProgramGroupPage=yes
PrivilegesRequired=admin
SetupLogging=yes
CloseApplications=yes
CloseApplicationsFilter=LocalTelemetry.exe,LocalTelemetry.Notifier.exe
[Messages]
StatusExtractFiles=Extracting application files...
StatusCreateIcons=Creating Start Menu & Desktop shortcuts...
[Tasks]
Name: startmenuicon; Description: "Create a &Start Menu shortcut"; GroupDescription: "Shortcuts:"
Name: desktopicon; Description: "Create a &Desktop shortcut"; GroupDescription: "Shortcuts:"
Name: startup; Description: "Run LocalTelemetry at Windows &startup"; GroupDescription: "System options:"
[Files]
Source: "publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "Uninstall.bat,*.xml"
[Icons]
Name: "{group}\LocalTelemetry"; Filename: "{app}\LocalTelemetry.exe"; Tasks: startmenuicon
Name: "{commondesktop}\LocalTelemetry"; Filename: "{app}\LocalTelemetry.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\LocalTelemetry.exe"; Description: "{cm:LaunchProgram,LocalTelemetry}"; Flags: nowait postinstall skipifsilent
[UninstallDelete]
Type: filesandordirs; Name: "{app}"
[Code]
const
StartupTaskName = 'LocalTelemetry Startup';
CSIDL_LOCAL_APPDATA = $001C;
ProfileListKey = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList';
PawnIoCleanupScript =
'$log = $env:TEMP + ''\pawnio_cleanup.log''' + #13#10 +
'''[PawnIO cleanup] started: '' + (Get-Date) | Set-Content $log' + #13#10 +
'if ($env:PROCESSOR_ARCHITECTURE -eq ''x86'' -or $env:PROCESSOR_ARCHITECTURE -eq ''ARM64'') { $pnp = Join-Path $env:windir ''Sysnative\pnputil.exe''; if (-not (Test-Path $pnp)) { $pnp = Join-Path $env:windir ''System32\pnputil.exe'' } } else { $pnp = Join-Path $env:windir ''System32\pnputil.exe'' }' + #13#10 +
'''[PawnIO cleanup] pnputil: '' + $pnp + '' exists: '' + (Test-Path $pnp) | Add-Content $log' + #13#10 +
'Start-Sleep -Seconds 2' + #13#10 +
'$rebootNeeded = $false' + #13#10 +
'$pnpLines = & $pnp /enum-drivers 2>&1' + #13#10 +
'$curOem = ''''' + #13#10 +
'$pawnioOems = @()' + #13#10 +
'foreach ($line in $pnpLines) {' + #13#10 +
' if ($line -match ''Published Name:\s+(oem\d+\.inf)'') { $curOem = $matches[1] }' + #13#10 +
' elseif ($line -match ''Original Name:\s+pawnio\.inf'') { if ($curOem) { $pawnioOems += $curOem } }' + #13#10 +
'}' + #13#10 +
'''[PawnIO cleanup] found OEM drivers: '' + ($pawnioOems -join '', '') | Add-Content $log' + #13#10 +
'foreach ($oem in $pawnioOems) {' + #13#10 +
' ''[PawnIO cleanup] deleting driver package: '' + $oem | Add-Content $log' + #13#10 +
' & $pnp /delete-driver $oem /uninstall /force *>&1 | Add-Content $log' + #13#10 +
' if ($LASTEXITCODE -eq 3010) { $rebootNeeded = $true }' + #13#10 +
'}' + #13#10 +
'& sc.exe stop PawnIO *>&1 | Add-Content $log' + #13#10 +
'& sc.exe delete PawnIO *>&1 | Add-Content $log' + #13#10 +
'if ($rebootNeeded) { exit 3010 } else { exit 0 }';
var
DownloadPage: TDownloadWizardPage;
DotNetDownloaded: Boolean;
RequiresReboot: Boolean;
function CreateStartupTask: Boolean;
var
Scheduler, RootFolder, Task, Trigger, Action: Variant;
begin
Result := False;
try try Scheduler := CreateOleObject('Schedule.Service');
Scheduler.Connect;
RootFolder := Scheduler.GetFolder('\');
Task := Scheduler.NewTask(0);
Task.RegistrationInfo.Description := 'Starts LocalTelemetry at user logon (silent, highest privileges).';
Task.Principal.LogonType := 3; // TASK_LOGON_INTERACTIVE_TOKEN
Task.Principal.RunLevel := 1; // TASK_RUNLEVEL_HIGHEST
Task.Settings.DisallowStartIfOnBatteries := False;
Task.Settings.StopIfGoingOnBatteries := False;
Task.Settings.ExecutionTimeLimit := 'PT0S';
Task.Settings.StartWhenAvailable := True;
Trigger := Task.Triggers.Create(9); // TASK_TRIGGER_LOGON
Trigger.Enabled := True;
Action := Task.Actions.Create(0); // TASK_ACTION_EXEC
Action.Path := ExpandConstant('{app}\LocalTelemetry.exe');
Action.Arguments := '--minimized';
Action.WorkingDirectory := ExpandConstant('{app}');
RootFolder.RegisterTaskDefinition(StartupTaskName, Task, 6, '', '', 3, '');
Result := True; finally Scheduler := Unassigned; RootFolder := Unassigned; Task := Unassigned; Trigger := Unassigned; Action := Unassigned; end; except
Log('CreateStartupTask failed: ' + GetExceptionMessage);
end;
end;
function IsDotNet10DesktopInstalled: Boolean;
var
FindRec: TFindRec;
begin
Result := False;
if FindFirst(ExpandConstant('{pf64}\dotnet\shared\Microsoft.WindowsDesktop.App\10.*'), FindRec) then
begin
try
repeat
if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then
begin
Result := True;
Break;
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
end;
procedure InitializeWizard;
begin
RequiresReboot := False;
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), 'Downloading .NET 10 Desktop Runtime...', nil);
DownloadPage.ShowBaseNameInsteadOfUrl := True;
end;
function PrepareToInstall(var NeedsRestart: Boolean): string;
var
ResultCode: Integer;
Attempt: Integer;
DownloadUrl: string;
begin
Result := '';
DotNetDownloaded := False;
if not IsDotNet10DesktopInstalled then
begin
for Attempt := 1 to 2 do
begin
// Attempt 1 uses aka.ms (evergreen redirect); Attempt 2 falls back directly to builds.dotnet.microsoft.com CDN
if Attempt = 1 then
DownloadUrl := 'https://aka.ms/dotnet/10.0/windowsdesktop-runtime-win-x64.exe'
else
DownloadUrl := 'https://builds.dotnet.microsoft.com/dotnet/WindowsDesktop/10.0.11/windowsdesktop-runtime-10.0.11-win-x64.exe';
DownloadPage.Clear;
DownloadPage.Add(DownloadUrl, 'dotnet_installer.exe', '');
DownloadPage.Show;
try
try
DownloadPage.Download;
DotNetDownloaded := True;
Log('.NET 10 Desktop Runtime downloaded successfully on attempt ' + IntToStr(Attempt) + '.');
Break;
except
Log('.NET 10 Desktop Runtime download failed on attempt ' + IntToStr(Attempt) + ': ' + GetExceptionMessage);
if DownloadPage.AbortedByUser then
begin
Result := 'Installation cancelled by user.';
Break;
end;
if Attempt = 2 then
begin
Result := 'Failed to download the required .NET 10 Desktop Runtime.' + #13#10 + #13#10 +
'Error: ' + GetExceptionMessage + #13#10 + #13#10 +
'Please ensure you have an active internet connection and run Setup again.';
end;
end;
finally
DownloadPage.Hide;
end;
end;
if DotNetDownloaded then
begin
WizardForm.StatusLabel.Caption := 'Installing .NET 10 Desktop Runtime...';
if not Exec(ExpandConstant('{tmp}\dotnet_installer.exe'), '/install /quiet /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
Result := 'Failed to install the .NET 10 Desktop Runtime. Setup cannot continue.';
end;
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
MarkerPath, PawnIoExe: string;
ResultCode: Integer;
begin
if CurStep = ssPostInstall then
begin
// Create 'app.mode' marker file inside application directory.
// AppSettings.cs checks for this file's existence to route settings to LocalAppData.
MarkerPath := ExpandConstant('{app}\app.mode');
SaveStringToFile(MarkerPath, 'standard', False);
// Install PawnIO sensor driver if downloaded during setup.
// This follows the bootstrapper pattern: clean stale state, install, retry, verify.
PawnIoExe := ExpandConstant('{app}\PawnIO_setup.exe');
if FileExists(PawnIoExe) then
begin
try
WizardForm.StatusLabel.Caption := 'Preparing kernel hardware sensor driver...';
// Step 1: Clean up any stale PawnIO service from a previous install/uninstall.
// Without this, PawnIO_setup.exe fails with 1072 (service marked for deletion).
Exec('sc.exe', 'stop PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Log('Pre-install: sc stop PawnIO exit code: ' + IntToStr(ResultCode));
Exec('sc.exe', 'delete PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Log('Pre-install: sc delete PawnIO exit code: ' + IntToStr(ResultCode));
// Give Windows SCM time to fully flush the deleted service handle
if ResultCode = 0 then
begin
Log('Pre-install: Waiting for Windows to flush stale service...');
Sleep(3000);
end;
// Step 2: Install PawnIO
WizardForm.StatusLabel.Caption := 'Installing kernel hardware sensor driver...';
Log('Installing PawnIO sensor driver from ' + PawnIoExe + '...');
if not Exec(PawnIoExe, '-install -silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
begin
Log('Failed to launch PawnIO setup executable');
end
else
begin
Log('PawnIO installer finished with exit code: ' + IntToStr(ResultCode));
// If we still get 1072, wait longer and retry once
if ResultCode = 1072 then
begin
Log('PawnIO install returned 1072 (stale service). Waiting 5s and retrying...');
WizardForm.StatusLabel.Caption := 'Waiting for driver cleanup to complete...';
Sleep(5000);
Exec('sc.exe', 'delete PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(2000);
WizardForm.StatusLabel.Caption := 'Retrying driver installation...';
if Exec(PawnIoExe, '-install -silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
Log('PawnIO retry finished with exit code: ' + IntToStr(ResultCode))
else
Log('PawnIO retry failed to launch');
end;
// Evaluate final result
if (ResultCode = 0) or (ResultCode = 183) or (ResultCode = 1056) then
begin
Log('PawnIO installation successful (exit code: ' + IntToStr(ResultCode) + ')');
end
else if ResultCode = 1072 then
begin
Log('PawnIO still returning 1072 after retry. Flagging for restart.');
RequiresReboot := True;
end
else
begin
Log('PawnIO installer returned unexpected exit code: ' + IntToStr(ResultCode));
end;
end;
// Step 3: Start the service immediately so the app can use it on first launch
if not RequiresReboot then
begin
WizardForm.StatusLabel.Caption := 'Starting hardware sensor driver...';
Sleep(1000);
Exec('sc.exe', 'start PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Log('Post-install: sc start PawnIO exit code: ' + IntToStr(ResultCode));
if (ResultCode <> 0) and (ResultCode <> 1056) then
begin
Log('PawnIO service failed to start. Will be started by app at runtime.');
end;
end;
except
Log('Exception during PawnIO installation: ' + GetExceptionMessage);
end;
end;
// Create the "Run at Windows startup" scheduled task if the user selected it.
// Uses the Task Scheduler COM API because schtasks.exe /Create /SC ONLOGON
// silently fails with 0x80004005 on some Windows 11 builds.
if WizardIsTaskSelected('startup') then
begin
if not CreateStartupTask then
MsgBox('LocalTelemetry could not be added to Windows startup. You can enable it later in Settings > General > "Start with Windows".', mbError, MB_OK);
end;
end;
end;
function IsAppRunning(const ExeName: string): Boolean;
var
ResultCode: Integer;
begin
Exec('cmd.exe', '/c tasklist /FI "IMAGENAME eq ' + ExeName + '" 2>NUL | find /I /N "' + ExeName + '" >NUL', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Result := (ResultCode = 0);
end;
procedure WaitForAppExit;
var
Waited: Integer;
begin
Waited := 0;
while (IsAppRunning('LocalTelemetry.exe') or IsAppRunning('LocalTelemetry.Notifier.exe')) and (Waited < 40) do
begin
Sleep(250);
Waited := Waited + 1;
end;
end;
function NeedRestart(): Boolean;
begin
Result := RequiresReboot;
end;
function InitializeSetup: Boolean;
var
ResultCode: Integer;
begin
Result := True;
if IsAppRunning('LocalTelemetry.exe') or IsAppRunning('LocalTelemetry.Notifier.exe') then
begin
if MsgBox('LocalTelemetry is currently running in the background.' + #13#10 + #13#10 +
'Setup needs to close LocalTelemetry before updating or reinstalling.' + #13#10 + #13#10 +
'Do you want Setup to close it automatically and continue?',
mbConfirmation, MB_YESNO) = IDYES then
begin
Exec('taskkill.exe', '/f /im LocalTelemetry.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/f /im LocalTelemetry.Notifier.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
WaitForAppExit;
end
else
begin
Result := False; // Cancel installation gracefully
end;
end;
end;
function DeleteUserData(const Dir: string): Boolean;
var
Attempt: Integer;
begin
Result := False;
for Attempt := 1 to 3 do
begin
if not DirExists(Dir) then
begin
Result := True;
Exit;
end;
if DelTree(Dir, True, True, True) then
begin
Result := True;
Exit;
end;
Sleep(500);
end;
end;
function CollectLocalTelemetryDataDirs(const Dirs: TStringList): Integer;
var
Profiles: TArrayOfString;
I: Integer;
ProfilePath, DataDir: string;
begin
Result := 0;
if RegGetSubkeyNames(HKLM, ProfileListKey, Profiles) then
for I := 0 to GetArrayLength(Profiles) - 1 do
begin
ProfilePath := '';
if RegQueryStringValue(HKLM, ProfileListKey + '\' + Profiles[I], 'ProfileImagePath', ProfilePath) then
begin
DataDir := ProfilePath + '\AppData\Local\LocalTelemetry';
if DirExists(DataDir) and (Dirs.IndexOf(DataDir) = -1) then
begin
Dirs.Add(DataDir);
Result := Result + 1;
end;
end;
end;
end;
function InitializeUninstall: Boolean;
var
ResultCode: Integer;
begin
Result := True;
if IsAppRunning('LocalTelemetry.exe') or IsAppRunning('LocalTelemetry.Notifier.exe') then
begin
if MsgBox('LocalTelemetry is currently running in the background.' + #13#10 + #13#10 +
'To proceed with uninstallation, the application needs to be closed.' + #13#10 + #13#10 +
'Do you want to close LocalTelemetry and continue uninstalling?',
mbConfirmation, MB_YESNO) = IDYES then
begin
Exec('taskkill.exe', '/f /im LocalTelemetry.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/f /im LocalTelemetry.Notifier.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end
else
begin
Result := False; // Cancel uninstallation
end;
end;
end;
var
UninstallDriverNeedsReboot: Boolean;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
TempDir, AppDir, PawnIoScript, PreservedMsg: string;
DataDirs, PendingDataDirs: TStringList;
Count, I: Integer;
ResultCode: Integer;
begin
if CurUninstallStep = usUninstall then
begin
// Remove the startup scheduled task created during install
Exec('schtasks.exe', '/Delete /TN "' + StartupTaskName + '" /F', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
// Force kill any running instances of main app and background notifier before file deletion
Exec('taskkill.exe', '/f /im LocalTelemetry.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/f /im LocalTelemetry.Notifier.exe /t', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
WaitForAppExit;
Sleep(2000); // Give the Windows kernel time to fully close the driver handles
// If PawnIO uninstaller binary exists, invoke it cleanly first
if FileExists(ExpandConstant('{app}\PawnIO_setup.exe')) then
Exec(ExpandConstant('{app}\PawnIO_setup.exe'), '-uninstall -silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
else if FileExists('C:\Program Files\PawnIO\PawnIO_setup.exe') then
Exec('C:\Program Files\PawnIO\PawnIO_setup.exe', '-uninstall -silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
// Remove the PawnIO kernel driver service, uninstall registry keys and files
Exec('sc.exe', 'stop PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('sc.exe', 'delete PawnIO', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
// Remove the PawnIO kernel driver package via script
PawnIoScript := ExpandConstant('{tmp}\pawnio_cleanup.ps1');
SaveStringToFile(PawnIoScript, PawnIoCleanupScript, False);
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -File "' + PawnIoScript + '"',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode);
// Clean up temporary script and logs
DeleteFile(PawnIoScript);
DeleteFile(ExpandConstant('{tmp}\pawnio_cleanup.log'));
DeleteFile(ExpandConstant('{commonappdata}\LocalTelemetry\pawnio_cleanup.log'));
RemoveDir(ExpandConstant('{commonappdata}\LocalTelemetry'));
if ResultCode = 3010 then
UninstallDriverNeedsReboot := True
else
UninstallDriverNeedsReboot := False;
RegDeleteKeyIncludingSubkeys(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PawnIO');
RegDeleteKeyIncludingSubkeys(HKLM, 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\PawnIO');
if DirExists('C:\Program Files\PawnIO') then
DelTree('C:\Program Files\PawnIO', True, True, True);
AppDir := ExpandConstant('{app}');
if DirExists(AppDir) then
DelTree(AppDir, True, True, True);
end
else if CurUninstallStep = usPostUninstall then
begin
// Driver uninstall status prompt deferred to end of uninstall
if UninstallDriverNeedsReboot then
begin
MsgBox('The PawnIO kernel driver was uninstalled, but Windows requires a system restart to fully release it from memory.' + #13#10 + #13#10 + 'If you plan to reinstall LocalTelemetry immediately, please restart your computer first.', mbInformation, MB_OK);
end;
// Prompt user to remove AppData user settings deferred to end of uninstall
PendingDataDirs := TStringList.Create;
DataDirs := TStringList.Create;
try
Count := CollectLocalTelemetryDataDirs(DataDirs);
if Count > 0 then
begin
if Count > 1 then
PreservedMsg := 'Do you also want to remove all saved settings, traffic logs and local hardware monitoring history for all ' + IntToStr(Count) + ' user profiles on this system?'
else
PreservedMsg := 'Do you also want to remove all saved settings, traffic logs and local hardware monitoring history?';
if MsgBox(PreservedMsg, mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then
begin
for I := 0 to DataDirs.Count - 1 do
if not DeleteUserData(DataDirs[I]) then
PendingDataDirs.Add(DataDirs[I]);
TempDir := GetShellFolderByCSIDL(CSIDL_LOCAL_APPDATA, False);
if TempDir <> '' then
begin
TempDir := TempDir + '\Temp\PawnIo';
if DirExists(TempDir) then
DelTree(TempDir, True, True, True);
end;
end
else
begin
PreservedMsg := 'Your settings, logs and monitoring history have been preserved at:' + #13#10;
for I := 0 to DataDirs.Count - 1 do
begin
if I > 0 then
PreservedMsg := PreservedMsg + #13#10;
PreservedMsg := PreservedMsg + DataDirs[I];
end;
MsgBox(PreservedMsg, mbInformation, MB_OK);
end;
end;
// Final retry for any user data folders that could not be deleted above
for I := 0 to PendingDataDirs.Count - 1 do
if DirExists(PendingDataDirs[I]) then
DeleteUserData(PendingDataDirs[I]);
finally
DataDirs.Free;
PendingDataDirs.Free;
PendingDataDirs := nil;
end;
end;
end;