From 43dde4eab8d2466961dd442bbae10533d4b4ed16 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 14 May 2021 15:29:46 +0300 Subject: [PATCH] UI: Installer: Stop/start service. --- deploy/FortFirewall.iss | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index 4aac7e0f..3e5f3534 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -67,7 +67,6 @@ Name: "{commondesktop}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}" [Run] Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"; Flags: runascurrentuser -Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; Flags: runascurrentuser nowait Filename: "https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads"; \ Description: "Install the latest Visual C++ x86 redistributable!"; Flags: shellexec postinstall; \ @@ -86,12 +85,20 @@ Type: files; Name: "{app}\qt*.*" Type: files; Name: "{app}\README*.*" [Code] -function PrepareToInstall(var NeedsRestart: Boolean): String; +function InitializeSetup(): Boolean; var ResultCode: Integer; begin - Exec('sc.exe', ExpandConstant('stop {#APP_SVC_NAME}'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode); - Result := ''; + if Exec('sc.exe', ExpandConstant('stop {#APP_SVC_NAME}'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then + if ResultCode = 0 then Sleep(100); // Let service to stop + Result := True; +end; + +procedure DeinitializeSetup(); +var + ResultCode: Integer; +begin + Exec('sc.exe', ExpandConstant('start {#APP_SVC_NAME}'), '', SW_HIDE, ewNoWait, ResultCode); end; function LanguageName(Param: String): String;