inno-installer: fix stop service before installation

This commit is contained in:
Markson committed 2023-06-27 20:20:43 +08:00
1 parent 5b53f6260d
commit cbace0dba3
2 files changed
+10 -34

No files matched your search

+5 -17
View File
@@ -70,22 +70,10 @@ Type: files; Name: "{app}\v2rayA-service.err.log"
Type: files; Name: "{app}\v2rayA-service.err.log.old"
[Code]
function InitializeSetup(): Boolean;
var
ResultCode: integer;
function InitializeSetup() : Boolean;
var
ResultCode: Integer;
begin
if FileExists('{dir}\v2rayA-service.exe') then
begin
if Exec(ExpandConstant('{sys}\sc.exe'), 'stop v2rayA', '', SW_HIDE,
ewWaitUntilTerminated, resultcode) then
begin
if (resultcode <> 0) then
begin
MsgBox('Failed to stop current v2rayA service, installation cannot continue, please try again!', mbInformation, MB_OK);
Result := False;
Exit;
end;
end;
end;
Result := True;
end;
Exec('cmd.exe', '/C sc.exe stop v2rayA', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end
+5 -17
View File
@@ -70,22 +70,10 @@ Type: files; Name: "{app}\v2rayA-service.err.log"
Type: files; Name: "{app}\v2rayA-service.err.log.old"
[Code]
function InitializeSetup(): Boolean;
var
ResultCode: integer;
function InitializeSetup() : Boolean;
var
ResultCode: Integer;
begin
if FileExists('{dir}\v2rayA-service.exe') then
begin
if Exec(ExpandConstant('{sys}\sc.exe'), 'stop v2rayA', '', SW_HIDE,
ewWaitUntilTerminated, resultcode) then
begin
if (resultcode <> 0) then
begin
MsgBox('Failed to stop current v2rayA service, installation cannot continue, please try again!', mbInformation, MB_OK);
Result := False;
Exit;
end;
end;
end;
Result := True;
end;
Exec('cmd.exe', '/C sc.exe stop v2rayA', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end