Inno Setup - local zip files before upgrade

When running new releases of my installer, I would like to back up the existing installation by adding the files to the zip archive.

I am currently able to back up my existing installation by copying the files to the backup destination. A simplified version of the method I'm using looks like this:

[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 do a zip instead?

+2


source to share


2 answers


Thanks to user 2976811 for your alternatives. I used TLama sugesstion and created my own DLL in Delphi (XE3) that zips the 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 ZipCompressFolder@MyZipLib.dll 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.

      

+2


source


you can check LOGAN ISSI: http://members.home.nl/albartus/inno/index.html there are some utilities related to it.

Another method would be to include a batch file that will perform the steps of the backup and then delete it when finished.

check out this stream: Batch script to zip all files without parent folder



however, due to the license, you are not allowed to link rar.dll with your application, so just apply this method but use package / dll that can be redistributed.

If you can use VBScript to encode a simple shell, you can also use zip compressed windows.

See How You: Can Windows Native ZIP Compression be scripted?

+2


source







All Articles