Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zip local files prior to an update with Inno Setup

Tags:

zip

inno-setup

When running new releases of my installer I would like to make a backup of an existing installation by adding files into a ZIP archive.

Currently, I am able to make a backup of an existing installation by coping the files to my Backup destination. A simplified version of the method I use is as follows:

[Files]
; Copy the contents of Bin folder to Backup folder. Skip if files don’t exist. 
Source: {app}\Bin\*;  DestDir: {app}\Backup\; \
    Flags: createallsubdirs external recursesubdirs uninsneveruninstall skipifsourcedoesntexist;

I would appreciate any ideas how I can zip instead?

like image 241
Lars Avatar asked Nov 19 '25 11:11

Lars


2 Answers

you may want to check out LOGAN ISSI : http://members.home.nl/albartus/inno/index.html there are some utils bundled with it.

Another method would be to include a batch file which will carry out the backup steps and then get it to remove itself once complete.

checkout this thread: Batch script to zip all the files without the parent folder

however due to licensing you are not allowed to bundle rar.dll with your app so just apply this method but use a package/dll which can be redistributed.

If you can use VBScript to code a simple wrapper you can also make use of windows built in zip compression.

See how you: Can Windows' built-in ZIP compression be scripted?

like image 75
majika Avatar answered Nov 21 '25 01:11

majika


I used TLama's suggestion and created my own DLL in Delphi (XE3) that zips a folder.

library MyZipLib;
uses
  Winapi.Windows,
  System.SysUtils,
  System.Zip;

{$R *.res}

function ZipCompressFolder(SourcePath, DestinationPath, ArchiveName : PChar): boolean; stdcall;
begin
  //If source folder does not exist then exit without error.
  if not DirectoryExists(SourcePath) then
  begin
    result := true;
    exit;
  end;

  try
    result := false;

    //Make sure destination path exists
    ForceDirectories(DestinationPath);
    TZipFile.ZipDirectoryContents(IncludeTrailingPathDelimiter(DestinationPath) + ArchiveName, SourcePath);
    result := true;
  except
    on E : Exception do MessageBox(0, PChar('Error calling function [email protected] with message: ' + E.Message + #13#10 + 'Source: ' + SourcePath + #13#10 + 'Dest: ' + DestinationPath+ #13#10 + 'Archive: ' + ArchiveName), 'MyZipLib.dll Error', MB_OK);
  end;
end;

exports ZipCompressFolder;
begin
end.
like image 21
Lars Avatar answered Nov 21 '25 01:11

Lars



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!