Additional improvements to installer

Fix installer to properly kill tray app.
Add icon and image to installer.
Add some sleep when stopping and removing service.
This commit is contained in:
Stewart Cossey
2021-01-07 02:39:31 +13:00
parent 2103d9a257
commit 64e76ff040
4 changed files with 21 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
#define TITLE "Technitium DNS Server"
#define FILES_LOCATION "..\..\DnsService\bin\Release"
#define TRAYAPP_LOCATION "..\..\DnsServerSystemTrayApp\obj\Release"
#define TRAYAPP_FILENAME "DnsServerSystemTrayApp.exe"
[Setup]
PrivilegesRequired=admin
@@ -18,10 +19,13 @@ AppCopyright=Copyright (c) 2021 {#COMPANY}
AppPublisher={#COMPANY}
OutputDir=..\Release
OutputBaseFilename=DnsServiceSetup
CloseApplications=no
Compression=lzma2/max
SetupIconFile=logo.ico
WizardSmallImageFile=logo.bmp
[Files]
Source: "{#TRAYAPP_LOCATION}\DnsServerSystemTrayApp.exe"; DestDir: "{app}";
Source: "{#TRAYAPP_LOCATION}\{#TRAYAPP_FILENAME}"; DestDir: "{app}"; BeforeInstall: KillTrayApp;
Source: "{#FILES_LOCATION}\*.*"; Excludes: "*.pdb,DnsService.exe"; DestDir: "{app}"; Flags: recursesubdirs;
Source: "{#FILES_LOCATION}\DnsService.exe"; DestDir: "{app}"; Flags: recursesubdirs; BeforeInstall: DoRemoveService; AfterInstall: DoInstallService;

View File

@@ -25,6 +25,18 @@ begin
Result := true;
end;
procedure TaskKill(fileName: String);
var
ResultCode: Integer;
begin
Exec(ExpandConstant('taskkill.exe'), '/f /im ' + '"' + fileName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure KillTrayApp; //Kill the tray app. Inno Setup cannot seem to close it through the "Close Applications" dialog.
begin
TaskKill('{#TRAYAPP_FILENAME}');
end;
procedure DoRemoveService(); //Removes the dns service from the scm
begin
if IsServiceInstalled(ExpandConstant('{cm:ServiceName}')) then begin
@@ -32,11 +44,12 @@ begin
if IsServiceRunning(ExpandConstant('{cm:ServiceName}')) then begin
Log('Service: Already running');
StopService(ExpandConstant('{cm:ServiceName}'));
Sleep(5000);
Sleep(3000);
end;
Log('Service: Remove');
RemoveService(ExpandConstant('{cm:ServiceName}'))
RemoveService(ExpandConstant('{cm:ServiceName}'));
Sleep(3000);
end;
end;
@@ -61,6 +74,7 @@ procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
KillTrayApp();
DoRemoveService();
end;
end;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB