Cr�er une archive auto-extractible (SFX)

Aspose.ZIP permet de cr�er une archive auto-extractible (SFX). Il s’agit d’un type sp�cial de fichier compress�, dont l’extension est .exe. Vous pouvez d�compresser un fichier auto-extractible en double-cliquant dessus.

Cr�ation d’archive auto-extractible

Pour composer une archive auto-extractible, instanciez SelfExtractorOptions et transmettez-la � ArchiveSaveOptions lors de l’enregistrement.

 1    using (FileStream zipFile = File.Open("archive.exe", FileMode.Create))
 2    {
 3        using (var archive = new Archive())
 4        {
 5            archive.CreateEntry("entry.bin", "data.bin");
 6            var sfxOptions = new SelfExtractorOptions() 
 7            { 
 8            ExtractorTitle = "Extractor", 
 9            CloseWindowOnExtraction = true, 
10            TitleIcon = "C:\pictorgam.ico" 
11            };
12            archive.Save(zipFile, new ArchiveSaveOptions() { SelfExtractorOptions = sfxOptions });
13        }
14    }

Ex�cution d’une archive auto-extractible

L’archive que vous produisez est ex�cutable et n�cessite .NET Framework 2.0 ou sup�rieur pour s’ex�cuter. Ces frameworks sont fournis avec Windows Vista et versions ult�rieures. Vous pouvez l’ex�cuter comme un programme normal en double-cliquant ou l’ex�cuter via l’interface de ligne de commande. Si vous souhaitez d�marrer l’extraction automatiquement, sp�cifiez l’option de ligne de commande � -autoExtract �. �chantillon:

1    C:\>archive.exe -autoExtract -password:T0p$ecret

Options de ligne de commande pour les archives auto-extractibles

OptionMeaningSample
-autoExtract

Primary option - without it decompression does not start.

Extraction starts automatically, other options apply.

sfx.exe -autoExtract
-autoCloseWindow closes when the extraction is complete. This option only makes sense if -autoExtract option is present.sfx.exe -autoExtract -autoClose
-forceOverwriteOverwrites all existing files without prompt if there are any. This option only makes sense if -autoExtract option present.sfx.exe -autoExtract -forceOverwrite
-password:

Provides a password to encrypted entries. This option only makes sense if -autoExtract option is present.

If you have spaces within the password quote it.

sfx.exe -autoExtract -password:T0p$ecret
-destination:

Extracts files to the supplied directory. This option only makes sense if -autoExtract option is present.

If you have spaces within the path quote it.

sfx.exe -autoExtract -destination:"C:\My Documents"

Vous pouvez utiliser ces options pour composer un script batch sous Windows.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.