windows installer fixes
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 1m19s
Release Binaries & Packages / Build & Release Standalone Binaries (Linux & Windows Cross-Compilation) (push) Successful in 9m48s

This commit is contained in:
2026-09-26 22:30:43 +02:00
parent ce7d2b97d2
commit 399cf469c5
6 changed files with 164 additions and 26 deletions
+50 -10
View File
@@ -91,9 +91,18 @@ end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
CfgPath, DestCfg: String;
begin
if CurStep = ssPostInstall then
if CurStep = ssInstall then
begin
Exec('net.exe', 'stop LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('sc.exe', 'stop LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM Win_Client.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(500);
end
else if CurStep = ssPostInstall then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Client', 'DataDir', GetDataDir(''));
@@ -108,28 +117,59 @@ end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
CustomDataDir, AppDir: String;
I: Integer;
CustomDataDir, AppDir, PowerShellCmd: String;
I, ResultCode: Integer;
begin
if CurUninstallStep = usPostUninstall then
if CurUninstallStep = usUninstall then
begin
AppDir := ExpandConstant('{app}');
Exec('net.exe', 'stop LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('sc.exe', 'stop LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if FileExists(AppDir + '\nssm.exe') then
begin
Exec(AppDir + '\nssm.exe', 'stop LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec(AppDir + '\nssm.exe', 'remove LOGAR_Client confirm', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
Exec('sc.exe', 'delete LOGAR_Client', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM Win_Client.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
PowerShellCmd := '-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "' +
'Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -like ''' + AppDir + '\*'' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"';
Exec('powershell.exe', PowerShellCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(1200);
end
else if CurUninstallStep = usPostUninstall then
begin
AppDir := ExpandConstant('{app}');
Exec('taskkill.exe', '/F /T /IM Win_Client.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Client', 'DataDir', CustomDataDir) then
begin
if (CustomDataDir <> '') and DirExists(CustomDataDir) then
DelTree(CustomDataDir, True, True, True);
begin
for I := 1 to 5 do
begin
if DelTree(CustomDataDir, True, True, True) or not DirExists(CustomDataDir) then
Break;
Sleep(300);
end;
end;
RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Client');
end;
AppDir := ExpandConstant('{app}');
if (AppDir <> '') and DirExists(AppDir) then
begin
for I := 1 to 5 do
for I := 1 to 10 do
begin
if DeleteFile(AppDir + '\nssm.exe') or not FileExists(AppDir + '\nssm.exe') then
DeleteFile(AppDir + '\nssm.exe');
DeleteFile(AppDir + '\Win_Client.exe');
DelTree(AppDir + '\runtime', True, True, True);
DelTree(AppDir + '\certs', True, True, True);
if DelTree(AppDir, True, True, True) or not DirExists(AppDir) then
Break;
Sleep(250);
Sleep(300);
end;
DelTree(AppDir, True, True, True);
end;
end;
end;
+25 -3
View File
@@ -105,6 +105,14 @@ FunctionEnd
Section "Install"
SetShellVarContext all
# Terminate any existing service or running processes before replacing files
ExecWait 'net stop LOGAR_Client'
ExecWait 'sc stop LOGAR_Client'
ExecWait 'taskkill /F /T /IM Win_Client.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
Sleep 500
SetOutPath "$INSTDIR"
File "../dist/Win_Client.exe"
File "../compilation/nssm.exe"
@@ -138,9 +146,22 @@ Section "Uninstall"
StrCpy $DATADIR "$APPDATA\LOGAR"
${EndIf}
ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Client'
ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Client confirm'
Sleep 500
# 1. Stop and remove service
ExecWait 'net stop LOGAR_Client'
ExecWait 'sc stop LOGAR_Client'
${If} ${FileExists} "$INSTDIR\nssm.exe"
ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Client'
ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Client confirm'
${EndIf}
ExecWait 'sc delete LOGAR_Client'
# 2. Force terminate any lingering processes
ExecWait 'taskkill /F /T /IM Win_Client.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
ExecWait 'powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Get-CimInstance Win32_Process | Where-Object { $$_.ExecutablePath -like ''$INSTDIR\*'' } | ForEach-Object { Stop-Process -Id $$_.ProcessId -Force -ErrorAction SilentlyContinue }"'
Sleep 1200
# 3. Clean up all installation and data files
RMDir /r "$INSTDIR\runtime"
RMDir /r "$INSTDIR\certs"
Delete "$INSTDIR\client_config.json"
@@ -152,4 +173,5 @@ Section "Uninstall"
RMDir /r "$INSTDIR"
RMDir /r "$DATADIR"
DeleteRegKey HKLM "Software\LOGAR\LOGAR-Client"
DeleteRegKey /ifempty HKLM "Software\LOGAR"
SectionEnd
+51 -10
View File
@@ -75,8 +75,18 @@ begin
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if CurStep = ssPostInstall then
if CurStep = ssInstall then
begin
Exec('net.exe', 'stop LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('sc.exe', 'stop LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM Server.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(500);
end
else if CurStep = ssPostInstall then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Server', 'DataDir', GetDataDir(''));
end;
@@ -84,28 +94,59 @@ end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
CustomDataDir, AppDir: String;
I: Integer;
CustomDataDir, AppDir, PowerShellCmd: String;
I, ResultCode: Integer;
begin
if CurUninstallStep = usPostUninstall then
if CurUninstallStep = usUninstall then
begin
AppDir := ExpandConstant('{app}');
Exec('net.exe', 'stop LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('sc.exe', 'stop LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if FileExists(AppDir + '\nssm.exe') then
begin
Exec(AppDir + '\nssm.exe', 'stop LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec(AppDir + '\nssm.exe', 'remove LOGAR_Server confirm', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
Exec('sc.exe', 'delete LOGAR_Server', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM Server.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
PowerShellCmd := '-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "' +
'Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -like ''' + AppDir + '\*'' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"';
Exec('powershell.exe', PowerShellCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(1200);
end
else if CurUninstallStep = usPostUninstall then
begin
AppDir := ExpandConstant('{app}');
Exec('taskkill.exe', '/F /T /IM Server.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('taskkill.exe', '/F /T /IM nssm.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Server', 'DataDir', CustomDataDir) then
begin
if (CustomDataDir <> '') and DirExists(CustomDataDir) then
DelTree(CustomDataDir, True, True, True);
begin
for I := 1 to 5 do
begin
if DelTree(CustomDataDir, True, True, True) or not DirExists(CustomDataDir) then
Break;
Sleep(300);
end;
end;
RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Server');
end;
AppDir := ExpandConstant('{app}');
if (AppDir <> '') and DirExists(AppDir) then
begin
for I := 1 to 5 do
for I := 1 to 10 do
begin
if DeleteFile(AppDir + '\nssm.exe') or not FileExists(AppDir + '\nssm.exe') then
DeleteFile(AppDir + '\nssm.exe');
DeleteFile(AppDir + '\Server.exe');
DelTree(AppDir + '\runtime', True, True, True);
DelTree(AppDir + '\certs', True, True, True);
if DelTree(AppDir, True, True, True) or not DirExists(AppDir) then
Break;
Sleep(250);
Sleep(300);
end;
DelTree(AppDir, True, True, True);
end;
end;
end;
+25 -3
View File
@@ -61,6 +61,14 @@ FunctionEnd
Section "Install"
SetShellVarContext all
# Terminate any existing service or running processes before replacing files
ExecWait 'net stop LOGAR_Server'
ExecWait 'sc stop LOGAR_Server'
ExecWait 'taskkill /F /T /IM Server.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
Sleep 500
SetOutPath "$INSTDIR"
File "../dist/Server.exe"
File "../compilation/nssm.exe"
@@ -88,9 +96,22 @@ Section "Uninstall"
StrCpy $DATADIR "$APPDATA\LOGAR-Server"
${EndIf}
ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Server'
ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Server confirm'
Sleep 500
# 1. Stop and remove service
ExecWait 'net stop LOGAR_Server'
ExecWait 'sc stop LOGAR_Server'
${If} ${FileExists} "$INSTDIR\nssm.exe"
ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Server'
ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Server confirm'
${EndIf}
ExecWait 'sc delete LOGAR_Server'
# 2. Force terminate any lingering processes
ExecWait 'taskkill /F /T /IM Server.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
ExecWait 'powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Get-CimInstance Win32_Process | Where-Object { $$_.ExecutablePath -like ''$INSTDIR\*'' } | ForEach-Object { Stop-Process -Id $$_.ProcessId -Force -ErrorAction SilentlyContinue }"'
Sleep 1200
# 3. Clean up all installation and data files
RMDir /r "$INSTDIR\runtime"
RMDir /r "$INSTDIR\certs"
Delete "$INSTDIR\server_config.json"
@@ -103,4 +124,5 @@ Section "Uninstall"
RMDir /r "$INSTDIR"
RMDir /r "$DATADIR"
DeleteRegKey HKLM "Software\LOGAR\LOGAR-Server"
DeleteRegKey /ifempty HKLM "Software\LOGAR"
SectionEnd