Rafat Mahmud
Rafat Mahmud

Reputation: 23

Installer programs (setup builders) that can manipulate data/ run scripts that can manipulate data for it?

I'm looking for an installer program (setup builder) that can manipulate data or basically run an external script to manipulate some data on the hard disk before running the actual setup file(primary .exe file to be installed) in order to facilitate the use of some customized user data for it to be compatible with a newer version of a software (to be installed).

Apparently merging the script with the primary .exe file isn't an option.

I've looked at packages like Inno Setup and createInstall but I can't seem to find my way around making them do the task.

Any help would be much appreciated !!

Upvotes: 2

Views: 149

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202222

With Inno Setup you can even merge the script in primary installer .exe file, as Inno Setup has built-in Pascal scripting functionality.

It's file-manipulation functions are rather limited, but maybe it's enough for your needs.

Very simple example:

[Code]

procedure InitializeSetup: Boolean;
var
  FileName: string;
  S: AnsiString;
begin
  { Prepend record to file.txt in user's Documents folder }
  FileName := ExpandConstant('{userdocs}\file.txt');

  if FileExists(FileName) and
     LoadStringFromFile(FileName, S) then
  begin
    S :=
      'another line - added on ' + 
      GetDateTimeString('ddddd tt', #0, #0) + #13#10 +
      S;
    SaveStringToFile(FileName, S, False);
  end;
end;

References:


If you cannot or do not want to use the pascal scripting, you can build a custom application, embed it into the installer and run it when the installer is starting.

[Files]
; Embed the executable to the installer,
; but do not install it (dontcopy flag)
Source: "preinstall.exe"; Flags: dontcopy

...
[Code]
procedure InitializeSetup: Boolean;
var
  ResultCode: Integer;
begin
  { Extract the executable to temp folder }
  ExtractTemporaryFile('preinstall.exe');

  { Run it }
  Result :=
    Exec(ExpandConstant('{tmp}\preinstall.exe'),
         '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);

  { If running fails or the executable indicates an error using }
  { non-zero exit code, abort installation }
  if (not Result) or (ResultCode <> 0) then
  begin
    MsgBox('Error preparing installation. Aborting.', mbError, MB_OK); 
    Exit;
  end;

  { Other initialization here }
end;

Upvotes: 1

Slappy
Slappy

Reputation: 5472

manipulate data or basically run an external script to manipulate some data on the hard disk

Inno Setup can do this - e.g. processing INI files, text files, configuration or XML files ... or executing batch files (.bat) which can execute scripts like SQL ...)

Please be more specific what you need.

Upvotes: 0

Related Questions