Oleg Sydorov
Oleg Sydorov

Reputation: 709

Using code (Exec function) in Inno Setup

I cannot use Exec function in my Inno Setup script.

I tried execute an example like:

var Code: Integer;
begin
  Exec('reg.exe', 'import C:\Support\*.reg', '', SW_HIDE, ewWaitUntilTerminated, Code)
end;

But no success, I have an error:

period '.' expected.

How can I execute my code (reg file)?

Upvotes: 0

Views: 3472

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202098

You cannot place your code like this without any context.

You have to place the code into some event function in the [Code] section:

For example CurStepChanged may be, what you want:

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
var
  Code: Integer;
begin
  if CurPageID = ssInstall then
  begin
    Exec('reg.exe', 'import C:\Support\*.reg', '', SW_HIDE, ewWaitUntilTerminated, Code);
  end;
end;

Upvotes: 1

Related Questions