P
P
Pavel Kaptur2017-05-02 10:43:18
Windows
Pavel Kaptur, 2017-05-02 10:43:18

How to correctly call to run your program from the installer?

Hello everyone, I've run into a problem. I wrote a small program that can be installed as a Windows service, made a basic installer and ran into a problem, if I run the installer during installation, a window pops up that says that "<Service name> uses files that must be updated during installation, etc. " I decided to write a procedure that will call my program with the service deletion parameter and the service type will not interfere with the installation. Wrote a function

function IsX64: Boolean;
begin
  Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
end;

function IsX86: Boolean;
begin
  Result := not IsX64;
end;

function PrepareToInstall(var NeedsRestart: Boolean) : String;
var
  ResultCode: Integer;
begin
  if IsX86 then
  begin
    Exec ('{syswow64}\MyService.exe', '-Service -sr', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
  end;
  if IsX64 then
  begin
    Exec ('{sys}\MyService.exe', '-Service -sr', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
  End;
  NeedsRestart := False;
  Result := '';
end;

How to do the installation without this window?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Kaptur, 2017-05-02
@drem1lin

Found an answer to your question. It turns out Inno Setup does not substitute names into strings. therefore, all calls must be made through ExpandConstant ()

D
dmfun, 2017-05-02
@dmfun

Just stop the service, the files will become available and the installer will be able to update them.
You can use the net stop command to stop the service.
If you delete the service, the service will not stop, anyway.. It will be marked as to be deleted and will be deleted after a reboot.
There is also an SC team.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question