Crear archivo autoextra�ble (SFX)

Aspose.ZIP permite crear un archivo autoextra�ble (SFX). Este es un tipo especial de archivo comprimido, que tiene una extensi�n de nombre de archivo.exe. Puede descomprimir un archivo autoextra�ble haciendo doble clic en �l.

Creaci�n de archivo autoextra�ble

Para componer un archivo autoextra�ble, cree una instancia de SelfExtractorOptions y p�sela a ArchiveSaveOptions al guardar.

 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    }

Ejecutando archivo autoextra�ble

El archivo que produce es ejecutable y requiere .NET Framework 2.0 o superior para ejecutarse. Estos marcos se suministran con Windows Vista y superior. Puede ejecutarlo como un programa normal haciendo doble clic o ejecutarlo a trav�s de la interfaz de l�nea de comandos. Si desea iniciar la extracci�n autom�ticamente, especifique la opci�n de l�nea de comando -autoExtract. Muestra:

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

Opciones de l�nea de comando para archivos autoextra�bles

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"

Puede utilizar esas opciones para componer Batch Script en Windows.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.